diff --git a/board/jungle/scripts/can_printer.py b/board/jungle/scripts/can_printer.py index 05cc802aa..292421a5c 100755 --- a/board/jungle/scripts/can_printer.py +++ b/board/jungle/scripts/can_printer.py @@ -19,20 +19,24 @@ def can_printer(): start = sec_since_boot() lp = sec_since_boot() - msgs = defaultdict(list) + all_msgs = defaultdict(list) + canbus = os.getenv("CAN") + if canbus == "3": + p.set_obd(True) + canbus = "1" + while True: can_recv = p.can_recv() - for address,dat, src in can_recv: - if canbus is None or str(src) == canbus: - msgs[address].append((dat, src)) + for addr, dat, bus in can_recv: + if canbus is None or str(bus) == canbus: + all_msgs[(addr, bus)].append((dat)) if sec_since_boot() - lp > 0.1: dd = chr(27) + "[2J" dd += "%5.2f\n" % (sec_since_boot() - start) - for k, v in sorted(msgs.items()): - last_msg, last_src = v[-1] - dd += "%d: %s(%6d): %s\n" % (last_src, "%04X(%4d)" % (k, k), len(v), binascii.hexlify(last_msg).decode()) + for (addr, bus), dat_log in sorted(all_msgs.items()): + dd += "%d: %s(%6d): %s\n" % (bus, "%04X(%4d)" % (addr, addr), len(dat_log), binascii.hexlify(dat_log[-1]).decode()) print(dd) lp = sec_since_boot() diff --git a/tests/can_printer.py b/tests/can_printer.py index 791f8e75d..404bc9dcf 100755 --- a/tests/can_printer.py +++ b/tests/can_printer.py @@ -20,20 +20,24 @@ def can_printer(): start = sec_since_boot() lp = sec_since_boot() - msgs = defaultdict(list) + all_msgs = defaultdict(list) + canbus = os.getenv("CAN") + if canbus == "3": + p.set_obd(True) + canbus = "1" + while True: can_recv = p.can_recv() - for address, dat, src in can_recv: - if canbus is None or str(src) == canbus: - msgs[address].append((dat, src)) + for addr, dat, bus in can_recv: + if canbus is None or str(bus) == canbus: + all_msgs[(addr, bus)].append((dat)) if sec_since_boot() - lp > 0.1: dd = chr(27) + "[2J" dd += "%5.2f\n" % (sec_since_boot() - start) - for k, v in sorted(msgs.items()): - last_msg, last_src = v[-1] - dd += "%d: %s(%6d): %s\n" % (last_src, "%04X(%4d)" % (k, k), len(v), binascii.hexlify(last_msg).decode()) + for (addr, bus), dat_log in sorted(all_msgs.items()): + dd += "%d: %s(%6d): %s\n" % (bus, "%04X(%4d)" % (addr, addr), len(dat_log), binascii.hexlify(dat_log[-1]).decode()) print(dd) lp = sec_since_boot()