Event objects Threading on Serial Port on Win32
el cintura partida
elcinturapartida at yahoo.es
Tue Jun 27 17:06:46 EDT 2006
Muchas gracias Gabriel por haberme informado, vos si
que es un profesional de la programación.
Un saludo,
David
--- Gabriel <gbsuar at gmail.com> escribió:
> David:
> Tube el mismo problema que vos con el hilo del
> ejemplo de pyserial. Me
> paso que en Linux andaba bien, obvio, pero tenia un
> pequeño
> problemilla en Windows, también obvio.
>
> Lo solucione de la siguiente manera:
> Asi es el codigo original de la función
> ComPortThread
>
> def ComPortThread(self):
> """Thread that handles the incomming
> traffic. Does the basic input
> transformation (newlines) and generates
> an SerialRxEvent"""
>
> while self.alive.isSet():
> #loop while alive event is true
> if self.ser.inWaiting() != 0:
> text = self.ser.read()
> event = SerialRxEvent(self.GetId(),
> text)
>
> self.GetEventHandler().AddPendingEvent(event)
>
>
> solo tiene que agregarle el siguiente bucle antes
> que nada:
> while not self.alive.isSet():
> pass
>
> quedándote así dicha función...
>
> def ComPortThread(self):
> """Thread that handles the incomming
> traffic. Does the basic input
> transformation (newlines) and generates
> an SerialRxEvent"""
> while not self.alive.isSet():
> pass
>
> while self.alive.isSet():
> #loop while alive event is true
> if self.ser.inWaiting() != 0:
> text = self.ser.read()
> event = SerialRxEvent(self.GetId(),
> text)
>
> self.GetEventHandler().AddPendingEvent(event)
>
> y listo... Con eso debería andar
> Espero haber sido útil
>
> --
> Gabriel
>
______________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com
More information about the Python-list
mailing list