From e7a4933efc9929074a23ac5a3705b0cfc7a7a4e1 Mon Sep 17 00:00:00 2001 From: Lukas Heintz <61192133+lukasloetkolben@users.noreply.github.com> Date: Sat, 28 Nov 2026 10:53:54 -0600 Subject: [PATCH] tools: remove pandas dependency from can_table, speed up can_print_changes (#39290) --- tools/scripts/car/can_print_changes.py | 15 ++++++++------- tools/scripts/car/can_table.py | 7 +++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/scripts/car/can_print_changes.py b/tools/scripts/car/can_print_changes.py index e466cd2968..8ddbc15238 100755 --- a/tools/scripts/car/can_print_changes.py +++ b/tools/scripts/car/can_print_changes.py @@ -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): diff --git a/tools/scripts/car/can_table.py b/tools/scripts/car/can_table.py index e2d9874fec..9e3cf24814 100755 --- a/tools/scripts/car/can_table.py +++ b/tools/scripts/car/can_table.py @@ -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