The plugin that is used is X10Mouse.
There is the following code that reads from serial port:
Code: Select all
def OnReceive(self, serialThread):
self.byteNum = 0
self.comBytes = [None, None, None]
data = serialThread.Read(1, self.timeout)
reply = {'suffix': None, 'payload': None}
lastEvent = None
while(len(data) > 0):
reply['suffix'] = self.Decode(reply, ord(data))
if (reply['suffix'] is not None) and (reply != lastEvent):
self.TriggerEnduringEvent(reply['suffix'], reply['payload'])
lastEvent = reply.copy()
reply['payload'] = None
data = serialThread.Read(1, self.timeout)
self.EndLastEvent()I changed the code to include debug prints in the following way:
Code: Select all
def OnReceive(self, serialThread):
self.byteNum = 0
self.comBytes = [None, None, None]
print "+++ OnReceive"
data = serialThread.Read(1, self.timeout)
reply = {'suffix': None, 'payload': None}
lastEvent = None
while(len(data) > 0):
print "Data:", data, hex(ord(data))
reply['suffix'] = self.Decode(reply, ord(data))
if (reply['suffix'] is not None) and (reply != lastEvent):
self.TriggerEnduringEvent(reply['suffix'], reply['payload'])
lastEvent = reply.copy()
reply['payload'] = None
data = serialThread.Read(1, self.timeout)
print "--- OnReceive"
self.EndLastEvent()And here is what I saw: lots of character drops in EG, while at the same time the stream of bytes is perfect.
Here is an example: the button pressed sends the same 3 bytes (in hex): 45 08 3f
And typically bytes 08 or 3f are dropped in EG output, only sometimes all 3 bytes in a row are read correctly.
Here is the log:
Code: Select all
.....
12:44:02 +++ OnReceive
12:44:02 Data: E 0x45
12:44:02 Data: ? 0x3f
12:44:02 Data: E 0x45
12:44:02 Data: ? 0x3f
12:44:02 --- OnReceive
12:44:05 +++ OnReceive
12:44:05 Data: E 0x45
12:44:05 Data: 0x8
12:44:05 Data: E 0x45
12:44:05 Data: ? 0x3f
12:44:05 --- OnReceive
12:44:07 +++ OnReceive
12:44:07 Data: E 0x45
12:44:07 Data: ? 0x3f
12:44:07 --- OnReceive
12:44:09 +++ OnReceive
12:44:09 Data: E 0x45
12:44:09 Data: 0x8
12:44:09 Data: E 0x45
12:44:09 Data: ? 0x3f
12:44:10 --- OnReceive
12:44:11 +++ OnReceive
12:44:11 Data: E 0x45
12:44:11 Data: 0x8
12:44:11 Data: E 0x45
12:44:11 Data: ? 0x3f
12:44:11 --- OnReceive
12:44:12 +++ OnReceive
12:44:12 Data: E 0x45
12:44:12 Data: 0x8
12:44:12 Data: E 0x45
12:44:12 Data: ? 0x3f
12:44:12 --- OnReceive
Code: Select all
Port closed
Capture stopped
Session started
Capture started on port COM3
Port opened
Set baud rate: 1200 bps
Set RTS: off
Set DTR: off
Set data bits: 7 bits
Set stop bits: 1 bit
Set parity: None
Set flow control: None
Set RTS: on
Set DTR: on
4d 45 08 3f 45 08 3f 45 08 3f 45 08 3f 45 08 3f ME.?E.?E.?E.?E.?
45 08 3f 45 08 3f 45 08 3f 45 08 3f 45 08 3f 45 E.?E.?E.?E.?E.?E
08 3f .?I have also attached serial terminal directly to COM port without EG running.
Here's what I see:
Code: Select all
Session started
[+] Opened port COM3 at 1200 bps
Status line(s) changed: DSR: on
Status line(s) changed: DSR: off
Status line(s) changed: DSR: on
Status line(s) changed: DSR: off
Status line(s) changed: DSR: on
Status line(s) changed: DSR: off
4d M
Status line(s) changed: DSR: on
Status line(s) changed: DSR: off
Status line(s) changed: DSR: on
Status line(s) changed: DSR: off
Status line(s) changed: DSR: on
Status line(s) changed: DSR: off
Status line(s) changed: DSR: on
Status line(s) changed: DSR: off
45 E
Status line(s) changed: DSR: on
Status line(s) changed: DSR: off
Status line(s) changed: DSR: on
Status line(s) changed: DSR: off
08 3f .?
Status line(s) changed: DSR: on
Status line(s) changed: DSR: off
Status line(s) changed: DSR: on
Status line(s) changed: DSR: off
Status line(s) changed: DSR: on
Status line(s) changed: DSR: off
Status line(s) changed: DSR: on
Status line(s) changed: DSR: off
Status line(s) changed: DSR: on
Status line(s) changed: DSR: off
45 08 3f E.?