Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
Fix log replay
Browse files Browse the repository at this point in the history
Fixes #152
  • Loading branch information
erikbosch committed Nov 7, 2023
1 parent 91c3091 commit 368fbfe
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions dbc2val/dbcfeederlib/canplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@ class CANplayer:
def __init__(self, dumpfile: str, can_port: str):
self._running = False
# open the file for reading can messages
log.info("Replaying CAN messages from log file %s", dumpfile)
self._messages = can.LogReader(dumpfile)
log.info("Starting repeated replay of CAN messages from log file %s", dumpfile)
self._dumpfile = dumpfile
self._can_port = can_port
log.debug("Using virtual bus to replay CAN messages (channel: %s)", self._can_port)
self._bus = VirtualBus(channel=can_port, bitrate=500000)

def _process_log(self):
# using MessageSync in order to consider timestamps of CAN messages
# and the delays between them
log_reader = can.MessageSync(messages=self._messages, timestamps=True)

messages = can.LogReader(self._dumpfile)
log_reader = can.MessageSync(messages=messages, timestamps=True)
for msg in log_reader:
if not self._running:
return
Expand All @@ -58,7 +60,6 @@ def _process_log(self):
log.debug("Sent message [channel: %s]: %s", self._bus.channel_info, msg)
except can.CanError:
log.error("Failed to send message via CAN bus")

log.info("Replayed all messages from CAN log file")

def _tx_worker(self):
Expand Down

0 comments on commit 368fbfe

Please sign in to comment.