PySerial rereads its own data
Greg Ewing (using news.cis.dfn.de)
g2h5dqi002 at sneakemail.com
Tue Jun 3 22:42:16 EDT 2003
Cliff Wells wrote:
>>>My question is this: why do I get back the data I just wrote? More to
>>>the point, how do I stop it?
I missed your original post, so this is just a guess, but
are you by any chance trying to use the same file object
to both read and write the serial port?
I made that mistake once in C, and I got exactly that
symptom. It seems that stdio gets its buffering in a
knot if you try to do that.
If that's the problem, the solution is to open the
serial device twice, once for reading and once for
writing, e.g.
fin = open("/dev/ttyS0", "r") # read from this one
fout = open("/dev/ttyS0", "w") # write to this one
--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list