serial port communication
Grant Edwards
grante at visi.com
Tue Mar 12 16:13:55 EST 2002
In article <3c8e6884.10907140 at news.planetis.com>, Hugo wrote:
> Hi,
>
> I try to have a communication between two computers using the serial
> ports.
>
> In the interpretor, I just try these instructions :
>>>> from os import *
>>>> fd = open ('/dev/ttyS0', O_RDWR)
>>>> write (fd, "a")
> 1
>>>> read (fd, 1)
> and everything stop : the read() instruction is probably waiting for
> something (I send a character from the other computer but it doesn't
> work) ?
Unless you've changed the port, it's probably in line-buffered
(cooked) mode, and it's waiting for a newline before it hands
over the line of text to you.
> a stop byte ? or I have use a "timeout" thing ? or the termios
> module ?
That depends on what you want it to do.
> I don't know !
We don't either !
There are a couple serial port libraries around that can make
life easier. Mine is strictly for Posix (Unix) systems:
ftp://ftp.visi.com/users/grante/python/PosixSerial.py
There are some others that are cross-platform, and Googling for
"serial" in comp.lang.python should find them.
--
Grant Edwards grante Yow! .. my NOSE is NUMB!
at
visi.com
More information about the Python-list
mailing list