Skip to content

Commit 3d48666

Browse files
committed
m1n1.fw.mtp: Fix parsing of init messages
Signed-off-by: Hector Martin <[email protected]>
1 parent b392c69 commit 3d48666

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

proxyclient/m1n1/fw/mtp.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ class GPIOInit(ConstructClass):
2020
class 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
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

@@ -275,6 +276,9 @@ def report(self, msg):
275276
ackmsg.unk = 0
276277
ackmsg.msg = msg
277278
self.device_control(ackmsg)
279+
else:
280+
self.log("Unknown message!")
281+
print(msg)
278282

279283
def ack(self, retcode, msg):
280284
msg = DeviceControlAck.parse(msg)

0 commit comments

Comments
 (0)