|
|
@ -4,7 +4,7 @@ import threading |
|
|
|
import serial |
|
|
|
|
|
|
|
class Serial(object): |
|
|
|
self._callbacks = dict() |
|
|
|
_callbacks = dict() |
|
|
|
|
|
|
|
def __init__(self, devicename='/dev/ttyUSB0', baudrate=115200): |
|
|
|
self.devicename = devicename |
|
|
@ -50,9 +50,10 @@ class Serial(object): |
|
|
|
print(data) |
|
|
|
command = data[0] |
|
|
|
argument = data[2:] |
|
|
|
cb = self._callbacks[command] |
|
|
|
if cb: |
|
|
|
cb(argument) |
|
|
|
if command in data: |
|
|
|
cb = self._callbacks[command] |
|
|
|
if cb: |
|
|
|
cb(argument) |
|
|
|
|
|
|
|
except serial.SerialException: |
|
|
|
pass |
|
|
|