From: Tom Hunger Date: Thu, 15 Jan 2015 16:34:31 +0000 (+0000) Subject: Start printer command_id at 10, not 0. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=0a1218778ce38b91c945102ae592c09e0397b026;p=sirius.git Start printer command_id at 10, not 0. 0 is an invalid value. It took me a while to debug this so please don't change. --- diff --git a/notes/capture_notes.md b/notes/capture_notes.md index 28f927e..69a8d73 100644 --- a/notes/capture_notes.md +++ b/notes/capture_notes.md @@ -110,8 +110,50 @@ itself is online. - users -# What happens when we send down an illegal print command: - -DEBUG:sirius.protocol.protocol_loop:Received UnknownEvent(raw_dict={u'device_address': u'000d6f000273ce0b', u'timestamp': 1421336620.588616, u'transfer_time': 3.43, u'bridge_address': u'000d6f0001b3719d', u'return_code': 144, u'rssi_stats': [-19, -19, -19], u'type': u'DeviceCommandResponse', u'command_id': 0}). - -Note the `return_code`. +# What is this? + +{u'device_address': u'000d6f000273ce0b', +u'timestamp': 1421336620.588616, +u'transfer_time': 3.43, +u'bridge_address': u'000d6f0001b3719d', +u'return_code': 144, +u'rssi_stats': [-19,-19,-19], +u'type': u'DeviceCommandResponse', +u'command_id': 0} + +Note the `return_code` of 144 (0x90). Looks like it is this: + + COMMAND_NAME_ID_MAP = { :set_delivery_and_print => 0x0001, + :set_delivery => 0x0002, + :set_delivery_and_print_no_face => 0x0011, + :set_delivery_no_face => 0x0012, + :set_personality => 0x0102, + :set_personality_with_message => 0x0101, + :set_quip => 0x0202, + :firmware_update => 0xf000 } + + RESPONSE_CODE_MAP = { :success => 0, + :eui64_not_found => 0x01, + :failed_network => 0x02, + :invalid_sequence => 0x20, + :busy => 0x30, + :invalid_size => 0x80, + :invalid_devicetype => 0x81, + :filesystem_error => 0x82, + :filesystem_invalid_id => 0x90, + :filesystem_no_free_filehandles => 0x91, + :filesystem_write_error => 0x92, + :bridge_error => 0xff } + + +# What happens when the binary payload has an extra 'x' at the end + before encoding: + +{u'device_address': u'000d6f000273ce0b', +u'timestamp': 1421339025.755868, +u'transfer_time': 3.44, +u'bridge_address': u'000d6f0001b3719d', +u'return_code': 128, +u'rssi_stats': [-19,-19,-19], +u'type': u'DeviceCommandResponse', +u'command_id': 0} diff --git a/sirius/protocol/protocol_loop.py b/sirius/protocol/protocol_loop.py index 22b54dc..2325c36 100644 --- a/sirius/protocol/protocol_loop.py +++ b/sirius/protocol/protocol_loop.py @@ -34,7 +34,9 @@ class BridgeState(object): self.websocket = websocket self.pending_commands = dict() self.connected_devices = set() - self.next_command_id = 0 + # NB 0 is an invalid command id (AKA file-id) so we start at + # 10. This took me an hour to debug, do not change! + self.next_command_id = 10 def send_message(device_address, message):