Event objects Threading on Serial Port on Win32

Discussion in 'Python' started by Gabriel, Jun 27, 2006.

  1. Gabriel

    Gabriel Guest

    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
    Gabriel, Jun 27, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    488
  2. Replies:
    0
    Views:
    575
  3. Pom
    Replies:
    2
    Views:
    1,627
    Bas-i
    Jan 31, 2007
  4. Levin Alexander

    win32 serial port suggestions?

    Levin Alexander, Jul 19, 2005, in forum: Ruby
    Replies:
    2
    Views:
    127
    Dibya Prakash
    Jul 20, 2005
  5. msalerno
    Replies:
    3
    Views:
    403
    Ilmari Karonen
    Jul 14, 2005
Loading...

Share This Page