Hi-
I'm experiencing crashes in my Win32 Python 2.7 application which appear
to be linked to pyzmq. At the moment, I can't even kill the "python.exe
*32" process in the Windows Task Manager. At the moment I'm running the
script using Ipython by calling
C:\Python27\pythonw.exe "/python27/scripts/ipython-qtconsole-script.pyw"
-pylab
but I also experience similar behavior when running within Eclipse.
I've included an error message at the end which appears in the Windows
'cmd' window, but the message is not reflected in the pylab window.
My attached device is transmitting <160><1><2><3><4><80> and is received
correctly when I run the sample pyserial script 'wxTerminal.py'. In my
application, however, the message appears to get characters out of order
or drop bytes.
If there's a better place to post or if you'd like more info, let me know.
Thanks,
Ethan
--Serial Port Listening
Thread
def MotorRxThread(self):
"""Thread that handles the incoming traffic. Does buffer input and
generates an SerialRxEvent"""
while self.alive.isSet(): #loop while alive event is true
text = self.serMotor.read(1) #read one, with timeout
if text:#check if not timeout
n = self.serMotor.inWaiting() #look if there is more to read
if n:
text = text + self.serMotor.read(n) #get it
#log to terminal
printstring = "MotorRxThread: "
for b in text:
printstring += str(ord(b)) + " "
print printstring
#pdb.set_trace()
if self.motorRx0.proc_string(text):
print "Message: cmd: " + str(self.motorRx0.cmd) + " data: " +
str(self.motorRx0.data)
event = SerialRxSpeedEvent(self.GetId(), text)
self.GetEventHandler().AddPendingEvent(event)
-\Serial Port Listening
Thread
Thread
Start&Stop--
def StartMotorThread(self):
"""Start the receiver thread"""
self.motorThread = threading.Thread(target=self.MotorRxThread)
self.motorThread.setDaemon(1)
self.alive.set()
self.motorThread.start()
def StopMotorThread(self):
"""Stop the receiver thread, wait until it's finished."""
if self.motorThread is not None:
self.alive.clear() #clear alive event for thread
self.motorThread.join() #wait until thread has finished
self.motorThread = None
self.serMotor.close() #close the serial port connection
\Thread
Start&Stop--
---Error message
ValueError: '' is not in list
([], ['', '', '',
'{"date":"2011-10-15T10:24:27.231000","username":"kernel","session":"82906c8a-1235-44d0-b65d-
0882955305c1","msg_id":"7cfcd155-bc05-4f47-9c39-094252223dab","msg_type":"stream"}',
'{"date":"2011-10-15T10:24:27.23100
0","username":"kernel","session":"82906c8a-1235-44d0-b65d-0882955305c1","msg_id":"f4b88228-b353-4cfb-9bbe-ae524ee1ac38",
"msg_type":"stream"}',
'{"date":"2011-10-15T10:24:00.774000","username":"username","session":"9f393860-c2ab-44e9-820d-8f
08ae35044e","msg_id":"13a46e93-8da2-487b-ab12-6cae47b1ac34","msg_type":"execute_request"}',
'{"date":"2011-10-15T10:24:0
0.774000","username":"username","session":"9f393860-c2ab-44e9-820d-8f08ae35044e","msg_id":"13a46e93-8da2-487b-ab12-6cae4
7b1ac34","msg_type":"execute_request"}', '{"data":"\\nMotorRxThread: 0
MotorRxThread: 4 ","name":"stdout"}'])
ERROR:root:Exception in I/O handler for fd object at 0x03ADFCC0>
Traceback (most recent call last):
File
"C:\Python27\lib\site-packages\pyzmq-2.1.9-py2.7-win32.egg\zmq\eventloop\ioloop.py",
line 291, in start
self._handlers[fd](fd, events)
File
"C:\Python27\lib\site-packages\pyzmq-2.1.9-py2.7-win32.egg\zmq\eventloop\stack_context.py",
line 133, in wrapped
callback(*args, **kwargs)
File "C:\Python27\lib\site-packages\IPython\zmq\kernelmanager.py",
line 448, in _handle_events
self._handle_recv()
File "C:\Python27\lib\site-packages\IPython\zmq\kernelmanager.py",
line 458, in _handle_recv
ident,msg = self.session.recv(self.socket)
File "C:\Python27\lib\site-packages\IPython\zmq\session.py", line
585, in recv
raise e
ValueError: No JSON object could be decoded
ERROR:root:Exception in I/O handler for fd object at 0x03ADFCC0>
Traceback (most recent call last):
File
"C:\Python27\lib\site-packages\pyzmq-2.1.9-py2.7-win32.egg\zmq\eventloop\ioloop.py",
line 291, in start
self._handlers[fd](fd, events)
File
"C:\Python27\lib\site-packages\pyzmq-2.1.9-py2.7-win32.egg\zmq\eventloop\stack_context.py",
line 133, in wrapped
callback(*args, **kwargs)
File "C:\Python27\lib\site-packages\IPython\zmq\kernelmanager.py",
line 448, in _hand