From d110079f946fa1066d1d29187dcee3a4a99333f5 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 10 Jun 2015 18:22:50 +0200 Subject: Compile fixes for comm, fix debug write --- rpi2/app/comm_arduino.py | 11 ++++------- rpi2/design.txt | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'rpi2') 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: -- cgit v1.2.1