PySerial rereads its own data

Grant Edwards grante at
Wed Jun 4 05:30:18 CEST 2003

In article <bbjl2p$a1ndg$1 at>, Greg Ewing (using wrote:

> 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 you're using open(), then stdio has nothing to do with it.

I've been doing Unix serial stuff for years and years, and I've always used
the same file descriptor for input and output without any problems.  I do it
every day in both C and Python.

> 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

Wait a minute. Are you talking about FILE pointers and fopen() or file
descriptors and open()?

Grant Edwards                   grante             Yow!  Where's SANDY DUNCAN?

More information about the Python-list mailing list