Serial Port
Grant Edwards
grante at visi.com
Mon Nov 18 10:55:46 EST 2002
In article <arahhn$urd$1 at news.netpower.no>, David Brown wrote:
> "Grant Edwards" <grante at visi.com> wrote in message
>
>> On a slight tangent, anybody know where there's documentation
>> or examples of doing stuff like overlapped serial I/O under
>> Win32 with events and callbacks and suchlike in Python? I
>> haven't found a copy of the Python on Win32 book yet...
>
> I find it easier to run serial communication in a seperate
> thread if I need asynchronous communication.
Yes, it's far easier to use a thread per port.
But my task is to try to troubleshoot serial driver bugs
triggered by certain sequences of Win32 system calls. My
customers are dyed-in-the-wool Win32 hacks who do things the
most obtuse, complex way possible. They love callbacks and I/O
completion ports and all that cruft. When they do stuff like
that and report problems, my requirement isn't to write a
program that performs serial I/O, it's to do it in a certain
way in order to reproduce problems reported by customers.
> You don't normally have so many serial ports open at a time
> that the threading overhead is significant,
I don't? I usually limit my test cases to 32 ports if
possible, but on occasion have to use 100+ ports.
> it is much easier than messing with the overlapped I/O stuff,
> and it is platform-independant.
Oh, I know it's easier doing sych I/O, and I don't care about
platform independance. I've never been asked to troubleshoot a
Win32 driver under Linux. :)
> To be entirely honest, though, the couple of Python programs I
> have written so far that use the serial port have not bothered
> with threading either - they just send out something, and wait
> for a reply or timeout (using the inWaiting() function from
> pyserial, along with time.sleep). But if I needed something
> more advanced, then I *would* use threads - I've done it in
> Delphi, and it works fine.
I use threads a lot for serial communications too. Sometimes
one-thread-per-port isn't what is required.
--
Grant Edwards grante Yow! I was giving HAIR
at CUTS to th' SAUCER PEOPLE
visi.com ... I'm CLEAN!!
More information about the Python-list
mailing list