Reading from serial port and dumping to console

Thomas Lim englim at pc.jaring.my
Fri Aug 20 05:33:44 EDT 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.

Regards,
Thomas.







More information about the Python-list mailing list