@@ -20,13 +20,13 @@ class GPIOInit(ConstructClass):
2020class InitBlock (ConstructClass ):
2121 subcon = Struct (
2222 "type" / Int16ul ,
23- "subtype" / Int16ul ,
2423 "length" / Int16ul ,
2524 "payload" / FixedSized (this .length ,
2625 Switch (this .type , {
2726 0 : HIDDescriptor ,
2827 1 : GPIOInit ,
29- 2 : Bytes (0 ),
28+ 2 : GreedyBytes , # Unknown 6 bytes terminator
29+ 7 : GreedyBytes , # Device name
3030 }, default = GreedyBytes ))
3131 )
3232
@@ -37,6 +37,7 @@ class InitMsg(ConstructClass):
3737 "unk" / Const (0x00 , Int8ul ),
3838 "device_id" / Int8ul ,
3939 "device_name" / PaddedString (16 , "ascii" ),
40+ "more_packets" / Int16ul ,
4041 "msg" / RepeatUntil (lambda obj , lst , ctx : lst [- 1 ].type == 2 , InitBlock )
4142 )
4243
@@ -254,7 +255,6 @@ def report(self, msg):
254255 self .log (f"Got HID descriptor for { iface } :" )
255256 iface .descriptor = blk .payload .descriptor
256257 self .log (hexdump (iface .descriptor ))
257- iface .initialize ()
258258 elif isinstance (blk .payload , GPIOInit ):
259259 self .log (f"GPIO Init: { blk .payload } " )
260260 prop = getattr (self .proto .node [msg .device_name ],
@@ -263,6 +263,8 @@ def report(self, msg):
263263 val = prop .args [1 ]
264264 self .log (f"GPIO key: { key } " )
265265 self .gpios [(msg .device_id , blk .payload .gpio_id )] = key , val
266+ if not msg .more_packets :
267+ iface .initialize ()
266268 elif isinstance (msg , GPIORequestMsg ):
267269 self .log (f"GPIO request: { msg } " )
268270 smcep = self .proto .smc .epmap [0x20 ]
@@ -275,6 +277,9 @@ def report(self, msg):
275277 ackmsg .unk = 0
276278 ackmsg .msg = msg
277279 self .device_control (ackmsg )
280+ else :
281+ self .log ("Unknown message!" )
282+ print (msg )
278283
279284 def ack (self , retcode , msg ):
280285 msg = DeviceControlAck .parse (msg )
0 commit comments