[Tutor] Reading garbage from serial port
helena bhaska
helena_b2001 at yahoo.com
Wed Feb 18 21:21:07 EST 2004
Hi,
I have a strange problem with reading data from a
serial port - I use pyserial package, here's the code:
ser = serial.Serial('/dev/ttyS0', 57600, timeout=None)
while 1:
x=ser.inWaiting()
if x!=0:
print x
buffer = ser.read(x)
ser.close()
If the device connected to my computer through the
serial port sends a bunch of data for some time, my
program thinks there is always data on the serial
port, even long after the device stops sending data -
it prints the same number for x (amount of data on the
port) continuously. I thought that reading data from
the serial port should clear it from the serial port,
but it seems like there is some garbage sitting there
all the time - how do I get rid of it? I've tried
flushing, but that does not fix the problem.
Thanks!
__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools
More information about the Tutor
mailing list