INNER CODE UNIT · Python
_on_message
Chanchaldhiman/CANviz · backend/canviz/cli.py:349
def _on_message(msg: can.Message) -> None:
arb_id = msg.arbitration_id
now = time.monotonic()
data = bytes(msg.data)
# J1939 decode
j1939_info: dict | None = None
if j1939_store_inst is not None:
j1939_info = j1939_store_inst.process_frame(
arb_id=arb_id,
data=data,
is_extended=msg.is_extended_id,
)
# process_frame returns pgn_hex/sa_hex but not always names.
# Look them up from the store's loaded pgn_db/sa_db directly.
if j1939_info and not j1939_info.get("pgn_name"):
pgn_db = getattr(j1939_store_inst, "pgn_db", {})
sa_db = getattr(j1939_store_inst, "sa_db", {})