Event objects Threading on Serial Port on Win32

Discussion in 'Python' started by elcinturapartida@yahoo.es, Aug 18, 2005.

  1. Guest

    Hello all,

    I am not sure if this question is about threading or serial i/o - it
    has elements of both. I'm on WinXP (desktop) and WinNT (labtop), when I
    run miniterm.py there is no problem both writing, reading, opening the
    com port, no errors, etc.

    But if I run wxTerminal.py when read from it nothing happens. It ran
    without error and it seemed to write ok, If I run the code to do the
    write, then I connect to the device through hyperterminal or wxterm, I
    get the response, so it seems the write is working ok, just very
    strange. wxTerminal.py uses Event object to set the event of Threading
    module. However wxTerminal.py doesn't loop while alive event is true.

    class TerminalFrame(wxFrame):
    """Simple terminal program for wxPython""

    def __init__(self, *args, **kwds):
    self.serial = serial.Serial()
    self.serial.timeout = 0.5 #make sure that the alive event can
    be checked from time to time
    self.settings = TerminalSetup() #placeholder for the settings
    self.thread = None
    self.alive = threading.Event()
    ....

    def StartThread(self):
    """Start the receiver thread"""
    self.thread = threading.Thread(target=self.ComPortThread)
    self.thread.setDaemon(1)
    self.thread.start()
    self.alive.set()
    ....

    def __attach_events(self):
    ...
    self.Bind(EVT_SERIALRX, self.OnSerialRead)
    self.Bind(EVT_CLOSE, self.OnClose)
    ....

    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
    print "Start self.alive.isSet" <----------------- Don't
    show in console.
    text = self.serial.read(1) #read one, with timout
    if text: #check if not timeout


    miniterm.py and wxTerminal.py are at http://pyserial.sourceforge.net/

    Any advice will be much appreciated.

    Thanks

    David
     
    , Aug 18, 2005
    #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:
    498
  2. Gabriel
    Replies:
    0
    Views:
    327
    Gabriel
    Jun 27, 2006
  3. Pom
    Replies:
    2
    Views:
    1,720
    Bas-i
    Jan 31, 2007
  4. Levin Alexander

    win32 serial port suggestions?

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

Share This Page