values of sys.platform? for a serial port lib

Chris Liechti cliechti at gmx.net
Sat Dec 29 19:41:29 EST 2001


Peter Hansen <peter at engcorp.com> wrote in
news:3C2E543D.4BFB07D at engcorp.com: 
> Between links on Unix, third-party serial port devices under
> Windows which might not use the COMx convention, and other such
> variations, I'd strongly recommend you *not* try to use an
> index origin of 0 but instead pass the open() routine (or
> whatever you have) a *string* naming the serial port.

i want it to run mainly on win32 and linux. the user of the lib should not 
need to care about device names.
i use a function to create the device string so the real numbering with 
numbers and/or letters is no problem.
 
i also have an optional argument to specify the port string, but when this 
is used it isn't portable anymore.

> By the way, does your win32 implementation work well with
> threads, if one thread is trying to read from the port while
> the other is trying to write to it?

i haven't tested it that way. i use it in a multi-threaded environment, but 
the class that accesses the serial port (and generates binary communication 
frames) uses means from the module threading.

the lib just calls the underlying functions from the os, so no thread 
safety from there.

chris

-- 
Chris <cliechti at gmx.net>




More information about the Python-list mailing list