pyserial problem: script stops reading

  • Thread starter Frederic Wenzel
  • Start date
F

Frederic Wenzel

I wrote a script on Linux that uses pyserial to read status messages
from a serial line using readlines(). For now, it just displays what
it gets on stdout:

17:42 | 0005 | 02 | | 5 |Rack Abs.| - | --210
17:42 | 0008 | 02 | | 5 |Rack Abs.| - | --210
17:42 | 0001 | 02 | | 5 |Rack Abs.| - | --210
17:43 | 0008 | 02 | | 5 |Rack Abs.| - | --210
17:43 | 0001 | 02 | | 5 |Rack Abs.| - | --210
17:43 | 0005 | 02 | | 5 |Rack Abs.| - | --210
17

After a few hours, or sometimes days, of listening, the script stops
in the middle of the line and does not display any further output (as
you can see with the "17" in the last line above). That happens, even
though I set a timeout of 10s when opening the line, and on timeout it
displays the lines and reopens the port:

ser = serial.Serial(port=1,
baudrate=1200,
rtscts=1,
timeout=10)

while 1:
lines = sh.readLines()
for line in lines:
print line
ser.close()
ser.open()

If the script does not time out there, I am not sure what else it is
doing. It seems to be in a wait state it does not get out of.

So even if the line received turned out to have some sort of error, I
think it should time out after a while? Maybe there is some sort of
buffer overrunning (even though the traffic is quite low: a line every
few minutes on average)?

Does anyone see any obvious error? Any hint how I can further debug the problem?

Thanks
Fred
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top