mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 08:33:42 +08:00
tools: remove pandas dependency from can_table, speed up can_print_changes (#39290)
This commit is contained in:
committed by
firestar5683
parent
9a28565710
commit
e7a4933efc
@@ -18,23 +18,24 @@ def update(msgs, bus, dat, low_to_high, high_to_low, quiet=False):
|
||||
|
||||
for y in x.can:
|
||||
if y.src == bus:
|
||||
dat[y.address] = y.dat
|
||||
addr, d = y.address, y.dat
|
||||
dat[addr] = d
|
||||
|
||||
i = int.from_bytes(y.dat, byteorder='big')
|
||||
l_h = low_to_high[y.address]
|
||||
h_l = high_to_low[y.address]
|
||||
i = int.from_bytes(d, byteorder='big')
|
||||
l_h = low_to_high[addr]
|
||||
h_l = high_to_low[addr]
|
||||
|
||||
change = None
|
||||
if (i | l_h) != l_h:
|
||||
low_to_high[y.address] = i | l_h
|
||||
low_to_high[addr] = i | l_h
|
||||
change = "+"
|
||||
|
||||
if (~i | h_l) != h_l:
|
||||
high_to_low[y.address] = ~i | h_l
|
||||
high_to_low[addr] = ~i | h_l
|
||||
change = "-"
|
||||
|
||||
if change and not quiet:
|
||||
print(f"{time.monotonic():.2f}\t{hex(y.address)} ({y.address})\t{change}{binascii.hexlify(y.dat)}")
|
||||
print(f"{time.monotonic():.2f}\t{hex(addr)} ({addr})\t{change}{binascii.hexlify(d)}")
|
||||
|
||||
|
||||
def can_printer(bus=0, init_msgs=None, new_msgs=None, table=False):
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import pandas as pd
|
||||
|
||||
import openpilot.cereal.messaging as messaging
|
||||
from openpilot.common.utils import tabulate
|
||||
|
||||
|
||||
def can_table(dat):
|
||||
@@ -12,9 +12,8 @@ def can_table(dat):
|
||||
r += [hex(b)]
|
||||
rows.append(r)
|
||||
|
||||
df = pd.DataFrame(data=rows)
|
||||
df.columns = [str(n) for n in range(7, -1, -1)] + [' ']
|
||||
table = df.to_markdown(tablefmt='grid')
|
||||
headers = [''] + [str(n) for n in range(7, -1, -1)] + [' ']
|
||||
table = tabulate([[i] + r for i, r in enumerate(rows)], headers, tablefmt='simple_grid')
|
||||
return table
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user