Skip to content

Commit

Permalink
Make flake8 happy :-)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Walz <[email protected]>
Signed-off-by: Andreas Lauser <[email protected]>
  • Loading branch information
Walz authored and Andreas Lauser committed Jan 12, 2024
1 parent d3b05c6 commit c3d38eb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
14 changes: 10 additions & 4 deletions dbcfeederlib/canreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion dbcfeederlib/dbcparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion dbcfeederlib/dbcreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit c3d38eb

Please sign in to comment.