By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,417 Members | 1,845 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,417 IT Pros & Developers. It's quick & easy.

pyserial problem: script stops reading

P: n/a
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
Sep 9 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.