serial and threads

Silke natunika at gmx.de
Tue Aug 17 12:06:15 EDT 2004


Hi again,

I already found a solution using 'threading' instead of 'thread' :-)

Ciao,

Silke


natunika at gmx.de (Silke) wrote in message news:<39ba6e78.0408170215.59f5bfc0 at posting.google.com>...
> Hi all!
> 
> I'm trying to write a program in python using the modules
> 'serialwin32' and 'thread' to create one thread that writes to a
> serial port and another one that reads from it at 'the same time'. My
> definitions are
> 
> def NetworkToSerial(input):
>         s.write(binascii.unhexlify(input))        
>         print "SENT: %s" % input                  
> 
> def SerialToNetwork():
>                 result = s.read(1)
>                 print "RECEIVED:"
>                 print binascii.hexlify(result) 
> 
> and I call them with
> 
> thread.start_new_thread(NetworkToSerial, (command,))             
> thread.start_new_thread(SerialToNetwork, ())
> 
> The first one seems to run fine, but for the second one I get the
> error message 'ClearCommError', 'the handle is invalid'.
> 
> Does anyone have a clue whether maybe serialwin32 is not
> thread-compatible?
> 
> Thanks for your help in advance!
> 
> Silke



More information about the Python-list mailing list