diff --git a/dbcfeederlib/canreader.py b/dbcfeederlib/canreader.py index dfe183b..0226a60 100644 --- a/dbcfeederlib/canreader.py +++ b/dbcfeederlib/canreader.py @@ -32,7 +32,8 @@ class CanReader(ABC): """ Provides means to read messages from a CAN bus. """ - def __init__(self, rxqueue: Queue, mapper: Mapper, can_port: str, dump_file: Optional[str] = None, can_fd:bool=False): + def __init__(self, rxqueue: Queue, mapper: Mapper, can_port: str, + dump_file: Optional[str] = None, can_fd: bool = False): """ This init method is only supposed to be called by subclass' __init__ functions. """ @@ -44,7 +45,12 @@ def __init__(self, rxqueue: Queue, mapper: Mapper, can_port: str, dump_file: Opt can_filters = mapper.can_frame_id_whitelist() log.info("Using CAN frame ID whitelist=%s", can_filters) - self._can_kwargs: Dict[str, Any] = {"interface": "socketcan", "channel": can_port, "can_filters": can_filters, "fd": can_fd} + self._can_kwargs: Dict[str, Any] = { + "interface": "socketcan", + "channel": can_port, + "can_filters": can_filters, + "fd": can_fd + } if dump_file is not None: self._can_kwargs["interface"] = "virtual" self._can_kwargs["bitrate"] = 500000 @@ -89,6 +95,7 @@ def _process_can_message(self, frame_id: int, data: Any): decode = message_def.decode(bytes(data), allow_truncated=True, decode_containers=True) except Exception as e: log.warning("Error processing CAN message with frame ID: %#x", frame_id, exc_info=True) + log.warning("Error: ", e) if log.isEnabledFor(logging.DEBUG): log.debug("Decoded message: %s", str(decode)) @@ -100,11 +107,10 @@ def _process_can_message(self, frame_id: int, data: Any): else: # handle container frame for tmp in decode: - if isinstance(tmp[1],bytes): + if isinstance(tmp[1], bytes): continue self._handle_decoded_frame(tmp[0], tmp[1], rx_time) - def _handle_decoded_frame(self, message_def, decoded, rx_time): for signal_name, raw_value in decoded.items(): # type: ignore signal: cantools.database.Signal = message_def.get_signal_by_name(signal_name) diff --git a/dbcfeederlib/dbcparser.py b/dbcfeederlib/dbcparser.py index 55e9250..237a9bb 100644 --- a/dbcfeederlib/dbcparser.py +++ b/dbcfeederlib/dbcparser.py @@ -118,7 +118,7 @@ def get_canid_for_signal(self, sig_to_find: str) -> Optional[int]: log.debug("Found signal %s in CAN message with frame ID %#x", signal.name, frame_id) self._signal_to_canid[sig_to_find] = frame_id return frame_id - + log.warning("Signal %s not found in CAN message database", sig_to_find) self._signal_to_canid[sig_to_find] = None return None diff --git a/dbcfeederlib/dbcreader.py b/dbcfeederlib/dbcreader.py index 78afbe1..0402e61 100644 --- a/dbcfeederlib/dbcreader.py +++ b/dbcfeederlib/dbcreader.py @@ -32,7 +32,8 @@ class DBCReader(canreader.CanReader): - def __init__(self, rxqueue: Queue, mapper: dbc2vssmapper.Mapper, can_port: str, can_fd: bool, dump_file: Optional[str] = None): + def __init__(self, rxqueue: Queue, mapper: dbc2vssmapper.Mapper, can_port: str, + can_fd: bool, dump_file: Optional[str] = None): super().__init__(rxqueue, mapper, can_port, dump_file, can_fd=can_fd) def _rx_worker(self):