waveform: fixes

This commit is contained in:
Simon Renblad 2024-01-15 10:58:25 +08:00
parent fa5d7fe877
commit 56660d6da2

View File

@ -516,7 +516,8 @@ class WaveformArea(QtWidgets.QWidget):
cw.update_x_max() cw.update_x_max()
maximum = self._state["stopped_x"] maximum = self._state["stopped_x"]
self._ref_axis.setLimits(xMax=maximum) self._ref_axis.setLimits(xMax=maximum)
self._ref_axis.setRange(xRange=(0, maximum)) if maximum is not None:
self._ref_axis.setRange(xRange=(0, maximum))
def on_cursor_move(self, x): def on_cursor_move(self, x):
self._cursor_x_pos = x self._cursor_x_pos = x
@ -680,7 +681,7 @@ class WaveformDock(QtWidgets.QDockWidget):
"data": dict(), "data": dict(),
} }
self._current_dir = "c://" self._current_dir = os.getcwd()
self.proxy_client = WaveformProxyClient(self._state, loop) self.proxy_client = WaveformProxyClient(self._state, loop)
devices_sub = Subscriber("devices", self.init_ddb, self.update_ddb) devices_sub = Subscriber("devices", self.init_ddb, self.update_ddb)
@ -756,22 +757,9 @@ class WaveformDock(QtWidgets.QDockWidget):
ddb = self._ddb ddb = self._ddb
trace = comm_analyzer.decoded_dump_to_waveform_data(ddb, decoded_dump) trace = comm_analyzer.decoded_dump_to_waveform_data(ddb, decoded_dump)
self._state.update(trace) self._state.update(trace)
self._dump = args self._dump = data
self.traceDataChanged.emit() self.traceDataChanged.emit()
def _decode_dump(self):
dump = self._dump
header = comm_analyzer.decode_header_from_receiver(*dump)
return comm_analyzer.decode_dump_loop(*header)
def _dump_header(self, endian, payload_length):
payload_length_word = struct.pack(endian + "I", payload_length)
if endian == ">":
endian_byte = b"E"
else:
endian_byte = b"e"
return endian_byte + payload_length_word
async def load_trace(self): async def load_trace(self):
try: try:
filename = await get_open_file_name( filename = await get_open_file_name(
@ -802,8 +790,7 @@ class WaveformDock(QtWidgets.QDockWidget):
self._current_dir = os.path.dirname(filename) self._current_dir = os.path.dirname(filename)
try: try:
with open(filename, 'wb') as f: with open(filename, 'wb') as f:
f.write(self._dump_header(dump[0], dump[1])) f.write(self._dump)
f.write(dump[2])
except Exception as e: except Exception as e:
logger.error("Failed to save analyzer trace: %s", e) logger.error("Failed to save analyzer trace: %s", e)