Reading from serial port and dumping to console

Thomas Lim englim at
Fri Aug 20 11:33:44 CEST 1999

I'm trying write a program to read from the serial port (barcode reader
attached) and dump to the console, so that my application program can
receive the data.
OS: Red Hat Linux 6
Python: 1.5.2

Program listing:
p = open('/dev/ttyS0', 'r')
t = open('/dev/tty0', 'w')
while 1:
    x = p.readline()
    print x   # yes, I could read from /dev/ttyS0
    t.write(x)  # but this has no effect on console

Hope that someone could help.


More information about the Python-list mailing list