pyserial problem: script stops reading
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 -- http://mail.python.org/mailman/listinfo/python-list
pyserial problem: script stops reading
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 -- http://mail.python.org/mailman/listinfo/python-list
Re: python readline error - please help - need it for scanner!
On 9/8/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > can configure, make and install > everything fine. I'm using python 2.4 I have ubuntu dapper drake. I am > trying to install hplip which requires python. When I do this, this > also works but while running the following error occurs: > Traceback (most recent call last): > File "/usr/local/bin/hp-setup", line 31, in ? > import readline, gzip > ImportError: No module named readline > > > It appears as though for some reaosn the readline module is not being > installed on my system. I suggest you uninstall python from your system: sudo apt-get remove python and reinstall it. Maybe something went wrong the first time you tried (reboot while installing or other crazy things). The python packages coming with Ubuntu are working pretty well, usually. Fred -- http://mail.python.org/mailman/listinfo/python-list
Re: pyserial problem: script stops reading
On 9/9/06, Hendrik van Rooyen <[EMAIL PROTECTED]> wrote: > | 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: > | (...) > | ser = serial.Serial(port=1, > | baudrate=1200, > | rtscts=1, > > if this is enabling hardware flow control try turning it off - at 1200 baud > you > should not need it Okay I disabled this for once. > | > | 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. > > Sounds more and more like flow control hassle - can you lay your hands on a > break out box or a datascope? Unfortunately not. I will run a few more tests without rtscts though. I am actually not horribly worried about kicking the serial reading service every once in a while, but it would be better if it detected the "stall" state itself... Thanks Fred -- http://mail.python.org/mailman/listinfo/python-list
Re: pyserial problem: script stops reading
On 9/9/06, Frederic Wenzel <[EMAIL PROTECTED]> wrote: > On 9/9/06, Hendrik van Rooyen <[EMAIL PROTECTED]> wrote: > > | 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: > > | (...) > > | ser = serial.Serial(port=1, > > | baudrate=1200, > > | rtscts=1, > > | > > | 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. When it stopped working again (unfortunately) I pressed ctrl c and got the following outputĂ– 14:53 | 0008 | 02 | | 5 |Rack Abs.| - | --752 14:53 | 0005 | 02 | | 2 |Rack Abs.| - | 00752 14:53 | 0008 | 02 |Traceback (most recent call last): File "serialhandler.py", line 34, in ? lines = sh.readLines() File "serialhandler.py", line 29, in readLines return self.ser.readlines() File "/usr/lib/python2.3/site-packages/serial/serialutil.py", line 78, in readlines line = self.readline(eol=eol) File "/usr/lib/python2.3/site-packages/serial/serialutil.py", line 60, in readline c = self.read(1) File "/usr/lib/python2.3/site-packages/serial/serialposix.py", line 269, in read ready,_,_ = select.select([self.fd],[],[], self._timeout) KeyboardInterrupt Apparently this is the place where it gets stuck. The select.select line does not return, not even for a timeout. Fred -- http://mail.python.org/mailman/listinfo/python-list