Hendrik van Rooyen schrieb:
On Friday 14 August 2009 14:13:46 greg wrote:

You can't read and write with the same stdio file object
at the same time. Odd things tend to happen if you try.

You need to open *two* file objects, one for reading
and one for writing:

   fr = open("/dev/ttyS0","rb",0)
   fw = open("/dev/ttyS0","wb",0)

and give fr to the reading thread and fw to the
writing thread.

Does this actually work without somehow falling foul of the fact that the /dev/ttyS0 is only one thing? - I know that there is no physical reason for not being able to go in and out at the same time - in my embedded stuff I do that routinely - but that is all assembler running on bare metal so it is under my own control.

You could also try avoiding file objects altogether
and use the raw system calls in the os module. Since
you're not using any buffering, there's little reason
to use the stdio layer. If you do that, you should be
able to use the same file descriptor for reading and
writing without any trouble.

Thanks for this - I now have my weekend cut out for me...

You should *really* just use pyserial. No hassle, instant satisfaction.

Diez
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to