Event objects Threading on Serial Port on Win32

E

elcinturapartida

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top