summaryrefslogtreecommitdiff
path: root/rpi2/app/comm_arduino.py
diff options
context:
space:
mode:
Diffstat (limited to 'rpi2/app/comm_arduino.py')
-rw-r--r--rpi2/app/comm_arduino.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/rpi2/app/comm_arduino.py b/rpi2/app/comm_arduino.py
index 884c325..b34f1d1 100644
--- a/rpi2/app/comm_arduino.py
+++ b/rpi2/app/comm_arduino.py
@@ -25,10 +25,7 @@ class Ctrl(object):
def is_control(b):
return (b & 0xC0) == 0x80
-def get_data_length(b):
- if (b & 0xC0) != 0x80:
- return 0
- return (b & 0x3f) - 4
+DATA_DEBUG_PREFIX = b'\xC0'
def configure_serial(path):
# Disables parameters which are not controlled by pyserial
@@ -63,8 +60,8 @@ class SerialState(object):
while True:
try:
return self.ser.read()
- except serial.SerialTimeoutException:
- pass
+ except serial.SerialTimeoutException as e:
+ _logger.warn('Read timeout: %s', e)
def handle_one(self, ser):
b = self._read_one(ser)
@@ -192,7 +189,7 @@ def handle_serial(path):
while True:
try:
data = state.handle_one(ser)
- if data and data[0] == b'\x80': # Debug packet
+ if data and data.startswith(DATA_DEBUG_PREFIX):
handle_data_debug(data[1:])
elif data:
_logger.info('PI DATA: %r', data)