]> git.aero2k.de Git - sirius.git/commitdiff
Start printer command_id at 10, not 0.
authorTom Hunger <tehunger@gmail.com>
Thu, 15 Jan 2015 16:34:31 +0000 (16:34 +0000)
committerTom Hunger <tehunger@gmail.com>
Thu, 15 Jan 2015 16:34:31 +0000 (16:34 +0000)
0 is an invalid value. It took me a while to debug this
so please don't change.

notes/capture_notes.md
sirius/protocol/protocol_loop.py

index 28f927e7c4f4f5254466f317678df274de06bec9..69a8d7374861cd6391b95cdaec0067e6d36e76f0 100644 (file)
@@ -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}
index 22b54dc01481935d91e711d67759b3c533400a11..2325c3653b315def9549c653e7d887ba72ad9a6e 100644 (file)
@@ -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):