Incompatible .pyd files with Python 2.0 (and win32comm)

Peter Hansen peter at engcorp.com
Thu Oct 19 00:40:44 EDT 2000


Mark Hammond wrote:
> 
> The good news is that later win32all builds (including 134) has a
> native serial port in the win32file module.
> win32\demos\win32comport_demo.py shows how to use it...
> 
> It could do with a high-level .py interface, but capturing all the
> possible semantics of the win32 api would be hard, so I just exposed
> it natively.

Thanks Mark, that's excellent!

I'm not sure exposing _all_ the semantics of the Win32 API is even a
good idea for many uses of Python.  Something more along the lines of a
cross-platform API would likely work better.  Perhaps the Java comm
stuff could be a model?  Or is that only for the Win32 environment?

I wonder if a fairly simple read()/write() interface would be suitable,
providing Python with a generic serial port API based on the existing
file/socket views of the world.  Our current efforts created a
SerialPort class as a subclass of an "abstract" Port class, with a few
cousins in other areas (CAN, GPIB) similarly subclassed from Port.  We
didn't try to support read/write, but with a little munging it might
turn out fairly clean.  I find it easier to adapt an application design
to a simple but clean API than to try to use (not to mention
understand!) all the parts of a not-so-clean API with a zillion bells
and whistles.  Overlapped I/O?  Uggh. :)

-- 
Peter Hansen
Kaval Telecom Inc.



More information about the Python-list mailing list