mirror of https://github.com/commaai/panda.git
Make can_print.py work on a all busses (#2070)
* Enable CAN3 printer (#1991) again
(cherry picked from commit 2b94e4fef7
)
* print messages with same address but on different bus
This commit is contained in:
parent
991c844731
commit
aab03bc4b6
|
@ -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()
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue