summaryrefslogtreecommitdiff
path: root/rpi2
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-06-10 18:22:50 +0200
committerPeter Wu <peter@lekensteyn.nl>2015-06-10 18:22:50 +0200
commitd110079f946fa1066d1d29187dcee3a4a99333f5 (patch)
tree27bbc6b6eb8078312db95e54284ba662987412a2 /rpi2
parentdad98df26e43dc08876270fa7cb575ed9bb36679 (diff)
downloadcode-d110079f946fa1066d1d29187dcee3a4a99333f5.tar.gz
Compile fixes for comm, fix debug write
Diffstat (limited to 'rpi2')
-rw-r--r--rpi2/app/comm_arduino.py11
-rw-r--r--rpi2/design.txt2
2 files changed, 5 insertions, 8 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)
diff --git a/rpi2/design.txt b/rpi2/design.txt
index 6957ad5..10c0c34 100644
--- a/rpi2/design.txt
+++ b/rpi2/design.txt
@@ -68,7 +68,7 @@ Data is interpreted as follows:
0... .... .... .... Bits that need to be updated (max 15). The length of the
following data depends on this.
-1000 0000 Debug packet, max len is determined by higher-level hdr.
+1100 0000 Debug packet, max len is determined by higher-level hdr.
Serial state machine: