Problem with two instances of PySerial

Grant Edwards invalid at invalid
Mon Jul 13 10:16:12 EDT 2009


> On Thu, 9 Jul 2009 08:40:18 -0500, Shine Jose <shinejose22 at gmail.com> wrote:

> I achieve this by creating a separate worker thread to poll
> the serial port for arrival of data and then updating the
> required widget in main thread of program. For polling the
> serial port, I create a separate instance of pySerial object.
> However, I am unable to read any data in the worker thread.
> Can the reason for this be 2 instances of pySerial objects
> being connected to serial port.

Yes.

> The reason I had this doubt was because Serial.Connect() in
> the worker thread did not throw any exception & isOpen()
> method returns true.

Under Unix, you are allowed to open a device or file as many
times as you want (there are some common cases where there is a
very useful thing to do).  However, for something like a serial
port, there's only one copy of each received data byte.
Depending on exactly how you structure your code, the incoming
data may be divided up amongst multiple readers, or one
particular reader may get all of it.

-- 
Grant Edwards                   grante             Yow! I joined scientology
                                  at               at a garage sale!!
                               visi.com            



More information about the Python-list mailing list