Checking for data on a serial port

Jay Freeman jayfreeman at earthlink.net
Tue Mar 28 14:47:42 EST 2000


Howdy,

I'm probably missing something obvious in the docs, but I'd like to have
a way to see if there is any data waiting to be read on a serial port.
I'm doing a touch screen driven app on RedHat 6.1. I've tried two
methods of reading the serial port and they both behave the same way.
I've just opened /dev/ttyS0 for read, and used readline(), and I've
redirected stdin and used raw_input(). Both methods just sit on that
statement and wait until some data comes in. What I'd like to do is
check and see if there is any data, if there is then read it, if not
then check the time against a default timeout value so I can kill some
intermediate screen that the user has walked away from and start the
session over (it's a kiosk). Neither termios or tty modules seem to be
able to do what I want (although termios is handy for flushing extra
touches out of the buffer). Any ideas?

Thanks,

Jay




More information about the Python-list mailing list