[Pythonmac-SIG] pyserial. am I using it wrong?
adam naples
adam.naples at yale.edu
Wed Nov 22 20:49:49 CET 2006
Hi, I'm running Tiger with a keyspan usb to serial adapter.
I'm trying to get python to communicate with an eye-tracker that
continually spits out coordinates
everything seems fine when I import the module, but it seems like it
only reads in the first 1020 lines of data when create a new serial
object and then stops listening to the serial port. When I use
flushInput() it empties the buffer, but then nothing comes back into
it, and I can verify that the eye-tracker is still sending.
the code is pretty much like this
>>>import serial
#make a serial object
>>>ser = serial.Serial('/dev/tty.KeySerial1', 19200, timeout=1)
>>> x = ser.readline()
>>> x
'\x82J\x00 263.0\t\r\n'
#now when I flush the input, because I want the up-to-date coordinates
#it empties the buffer
>>> ser.flushInput()
>>>ser.inWaiting()
0L
>>>ser.readline()
''
#I would expect that it would flush the input buffer and let me get
at the most current set of coordinates, but instead I get nothing
is something wrong with pyserial? am I using it wrong? if I use
director(ugh) it reads the serial data just fine, and continually.
any help would be great.
thanks
-an
More information about the Pythonmac-SIG
mailing list