Pyserial problem. script stops reading.

Hendrik van Rooyen mail at microcorp.co.za
Tue Sep 12 02:34:15 EDT 2006


"Frederic Wenzel" <fred at osuosl.org> Wrote:

>On 9/9/06, Frederic Wenzel <freeed at gmail.com> wrote:
>> On 9/9/06, Hendrik van Rooyen <mail at microcorp.co.za> 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

This seems a real PITA - it looks normal to me - it is as if the device has
simply stopped sending for some reason.  Can you:

1) set the external device up to ignore flow control?
2) check the cable for loose connections - wriggling it around while the
transmission is running might point at something - but be gentle - else you can
easily draw false conclusions, or break something that is in fact ok...

does anybody else know how to check the value of the time out, what its for and
what happens when it times out?

- hth - Hendrik

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060912/f96e7df9/attachment.html>


More information about the Python-list mailing list