pyserial / pyserial

Python serial port access library
Other
3.2k stars 1.11k forks source link

in_waiting property returns 0 instead of data #714

Open amirt23 opened 1 year ago

amirt23 commented 1 year ago

Hello

While using this library which incorporates pyserial within it I've encountered a problem reading from a HW (GNSS receiver). The first attempt connecting to the HW succeeds. However, after terminating the script\object operation and using the close property to close the connection, subsequent attempts of reading data are failing. This is evident by the in_waiting property returning 0 although the HW is sending out data. Only after a power cycle proper data streaming is restored. Could this have to do with the connection process running as a thread ?

I'm running the code on a machine with ARM Cortex-A78AE CPU, on ubuntu 20.04 using the pycharm IDE.

Thanks in advance, I appreciate the asstiance.

dylanwal commented 1 year ago

Hi, Is the following sentence referring to power cycling the CPU or GNSS receiver? "Only after a power cycle proper data streaming is restored."

If it is the GNSS receiver, then it is likely and issue with the other library sending data that the GNSS receiver no longer understands (the communication has gotten out of sync and the GNSS receiver does not understand the data sent so it doesn't respond. which is why you get zero 'in_waiting' data - no data was sent from the GNSS to receiver.)

If its the CPU, I am less sure what the issue is. It may be the same issue where the communication is getting out of sync and restating the CPU also resets the GNSS communication.

either way the zero in 'in_waiting' is telling you the GNSS is not sending any data back to the CPU. Its unlikely to be an issue with pyserial, but rather a bug in the other library and what messages it is sending.