From cc6b58f13e5aeac77f2cbd3e5c9527effbc0adc2 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Sat, 26 Nov 2022 17:49:11 +0100 Subject: [PATCH] m1n1.fw.dcp: Parse AVPropChunks in parse_log Signed-off-by: Janne Grunau --- proxyclient/m1n1/fw/dcp/ipc.py | 4 +++ proxyclient/m1n1/fw/dcp/parse_log.py | 44 ++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/proxyclient/m1n1/fw/dcp/ipc.py b/proxyclient/m1n1/fw/dcp/ipc.py index bc7226f2..7795b9c2 100644 --- a/proxyclient/m1n1/fw/dcp/ipc.py +++ b/proxyclient/m1n1/fw/dcp/ipc.py @@ -952,3 +952,7 @@ class Call: method.print_long_args(indent, self.in_vals, self.out_vals) #if len(method.out_fields) - (self.ret is not None): #print(self.out_vals) + + def get_method(self): + cls, method = ALL_METHODS.get(self.msg, (None, None)) + return method diff --git a/proxyclient/m1n1/fw/dcp/parse_log.py b/proxyclient/m1n1/fw/dcp/parse_log.py index edb72607..2498e707 100644 --- a/proxyclient/m1n1/fw/dcp/parse_log.py +++ b/proxyclient/m1n1/fw/dcp/parse_log.py @@ -4,6 +4,34 @@ from m1n1.utils import * from m1n1.constructutils import Ver from m1n1.fw.dcp.ipc import * +class DCPAVPropHandler: + def __init__(self): + self.dcpav_prop = {} + + def setDCPAVPropStart(self, length): + # print(f"setDCPAVPropStart({length:#x})") + self.dcpav_prop_len = length - 1 # off by one? + self.dcpav_prop_off = 0 + self.dcpav_prop_data = [] + return True + + def setDCPAVPropChunk(self, data, offset, length): + # print(f"setDCPAVPropChunk(..., {offset:#x}, {length:#x})") + assert offset == self.dcpav_prop_off + self.dcpav_prop_data.append(data) + self.dcpav_prop_off += len(data) + return True + + def setDCPAVPropEnd(self, key): + # print(f"setDCPAVPropEnd({key!r})") + blob = b"".join(self.dcpav_prop_data) + assert self.dcpav_prop_len == len(blob) + self.dcpav_prop[key] = OSSerialize().parse(blob) + self.dcpav_prop_data = self.dcpav_prop_len = self.dcpav_prop_off = None + pprint.pprint(self.dcpav_prop[key]) + return True + + def parse_log(fd): op_stack = {} for line in fd: @@ -34,8 +62,24 @@ def dump_log(fd): "": 0, "OOB": 0, } + + handler = DCPAVPropHandler() + for op in parse_log(fd): ctx = "" + if Ver.check("V < V13_2"): + dcpavprop_cbs = ["D122", "D123", "D124"] + else: + dcpavprop_cbs = ["D125", "D126", "D127"] + if not op.complete and op.msg in dcpavprop_cbs: + method = op.get_method() + if op.msg == dcpavprop_cbs[0]: + method.callback(handler.setDCPAVPropStart, op.in_data) + if op.msg == dcpavprop_cbs[1]: + method.callback(handler.setDCPAVPropChunk, op.in_data) + if op.msg == dcpavprop_cbs[2]: + method.callback(handler.setDCPAVPropEnd, op.in_data) + if "OOB" in op.chan: ctx = "[OOB] -----------> " if not op.complete: