program hangs when no data received from serial

bamischijf

New member
Joined
Mar 16, 2018
Messages
3
Programming Experience
1-3
Hello,

i have made program which can receive data from a serial input. If i choose the wrong com port or disable the com port. The program is stuck. It doesn't give an error but i can't use it anymore.
I think it is because it can't use readline() from the serial anymore but I don't know how to solve this problem.

I hope you can help me!

Thanks a lot
 
If you want us to be able to help you fix your code, actually showing us that code might be useful. Only the code relevant to the problem though, please.

I can't send the code because i am working for a school project. But the problem is: choosing the wrong COM port will freeze the program because it is waiting for readline() to receive data.
I am looking for a solution which wait 10 seconds after selecting the COM port to receive data.
If it doesn't receive data it must give an error message to the user and you are able to choose another COM port.

I can't find a good function to check if a COM Port is sending data--> true or false, but i only find functions to read data.
 
I can't send the code because i am working for a school project. But the problem is: choosing the wrong COM port will freeze the program because it is waiting for readline() to receive data.
I am looking for a solution which wait 10 seconds after selecting the COM port to receive data.
If it doesn't receive data it must give an error message to the user and you are able to choose another COM port.

I can't find a good function to check if a COM Port is sending data--> true or false, but i only find functions to read data.

oh i find a solution for my problem. I was working with a timer and every second calling a readline(). I now use the DataReceived handler and the problem of freezing is solved.
But still a problem is, if i choose the wrong COM port and don't receive data. I want to show a message that there is no data receiving. But i can't find the opposite of DataReceived. DataNotReceived does not exist haha.
 
Back
Top Bottom