Hi,
I'm quite new to Jython and Java (a few days). Here is a piece of code I
wrote to sub-class the SerialPortEventListener of the javax.comm package:
class MySerialPortEventListener (comm.SerialPortEventListener):
def serialEvent (self, Event):
print Event
try:
IBuf = '--------'
ILen = IStream.available()
while ILen > 0:
INum = IStream.read(IBuf)
print 'Read: OK', ILen, INum, IBuf
ILen = IStream.available()
except:
raise
I get the following result for each character sent to the serial port (with
help of a connected PSION)
javax.comm.SerialPortEvent[source=COM2]
Read: OK 1 1 --------
What goes right:
- The EventListener works and is fired correctly
- The InputStream reports that data is available (1 byte)
- The InputStream.read method call reports that it has read data
What goes wrong:
- The buffer doesn't contain any data except the 8 '-'s that I have put in
it for initialising
Please help, ... what am I missing?!?
(The other way around works. I managed to send data)
Thanks for any help and, once again, 'Jython is great'
Marc
|