waveform: fix to easier protocol

This commit is contained in:
Simon Renblad 2024-01-11 13:13:05 +08:00
parent 082962df2f
commit fed15816c4

View File

@ -751,29 +751,14 @@ class WaveformDock(QtWidgets.QDockWidget):
"value": (0, "log")
})
def on_dump_receive(self, *args):
header = comm_analyzer.decode_header_from_receiver(*args)
decoded_dump = comm_analyzer.decode_dump_loop(*header)
def on_dump_receive(self, data):
decoded_dump = comm_analyzer.decode_dump(data)
ddb = self._ddb
trace = comm_analyzer.decoded_dump_to_waveform_data(ddb, decoded_dump)
self._state.update(trace)
self._dump = args
self.traceDataChanged.emit()
def on_dump_read(self, dump):
endian_byte = dump[0]
if endian_byte == ord("E"):
endian = '>'
elif endian_byte == ord("e"):
endian = '<'
else:
logger.warning("first byte is not endian")
raise ValueError
payload_length_word = dump[1:5]
payload_length = struct.unpack(endian + "I", payload_length_word)[0]
data = dump[5:]
self.on_dump_receive(endian, payload_length, data)
def _decode_dump(self):
dump = self._dump
header = comm_analyzer.decode_header_from_receiver(*dump)
@ -800,7 +785,7 @@ class WaveformDock(QtWidgets.QDockWidget):
try:
with open(filename, 'rb') as f:
dump = f.read()
self.on_dump_read(dump)
self.on_dump_receive(dump)
except Exception as e:
logger.error("Failed to open analyzer trace: %s", e)