Il 17/09/2015 11:42, Chris Angelico ha scritto:
On Thu, Sep 17, 2015 at 7:28 PM, pozz <pozzu...@gmail.com> wrote:
At startup I open the ports and create and start a thread to manage the
receiving. When a byte is received, I call the .write() method for all the
other ports.
It works, but sometimes it seems to block. I think I haven't used correctly
the threads.
Seems a fairly reasonable model. From what I'm seeing here, you start
a thread to read from each serial port, but then those threads will
make blocking writes to all the other serial ports. Is it possible
that one of them is getting full?
When I do this kind of thing with TCP/IP sockets, I usually end up
having to go non-blocking in both directions, and maintaining a buffer
of unsent text for each socket. You may find that you need to do the
same thing here.
How to have a non-blocking write?
Maybe the problem happens when port 1 thread is in .read() (it blocks
for 1 second) and port 2 thread tries to write one byte (that was just
received) to port 1.
Where's the code getting blocked?
I don't knwo exactly. I can only see no more bytes are received on COM
ports.
--
https://mail.python.org/mailman/listinfo/python-list