Skip to content

Commit 49fcbc4

Browse files
committed
can testbench can now properly graph
can logs with relative timestamps
1 parent b1a0a34 commit 49fcbc4

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

can_testbench.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,13 +1659,28 @@ def setupLogMessages(self, log_file):
16591659
for msg in self.txMsgs:
16601660
tx_dict[msg.message.frame_id] = msg
16611661
with open(log_file) as f:
1662+
timestamp = None
1663+
firstMsg = None
1664+
for msg in pycan.CanutilsLogReader(f):
1665+
if msg is not None:
1666+
firstMsg = msg
1667+
break
1668+
1669+
if firstMsg is not None and firstMsg.timestamp < 1e9:
1670+
timestamp = 0
1671+
16621672
for msg in pycan.CanutilsLogReader(f):
16631673
if msg.is_rx:
16641674
key = rx_dict.get(msg.arbitration_id)
16651675
else:
16661676
key = tx_dict.get(msg.arbitration_id)
16671677
if key:
1668-
key.timestamps.append(msg.timestamp)
1678+
if timestamp is not None:
1679+
timestamp += msg.timestamp
1680+
key.timestamps.append(timestamp)
1681+
else:
1682+
key.timestamps.append(msg.timestamp)
1683+
16691684
signalValues = key.message.decode(msg.data)
16701685
for sig in key.signals:
16711686
value = signalValues.get(sig.signal.name)

0 commit comments

Comments
 (0)