469,336 Members | 5,570 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

Event objects Threading on Serial Port on Win32

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
Jun 27 '06 #1
0 1783

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by willie | last post: by
reply views Thread by elcinturapartida | last post: by
1 post views Thread by Ray Ackley | last post: by
15 posts views Thread by aikwee | last post: by
12 posts views Thread by Jack Russell | last post: by
6 posts views Thread by Casey Bralla | last post: by
3 posts views Thread by geskerrett | last post: by
saranjegan
reply views Thread by saranjegan | last post: by
24 posts views Thread by =?Utf-8?B?U3dhcHB5?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.