From 7b4a538eaad533a5000c109496cf266147e89de6 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 12 Aug 2024 17:41:08 -0500 Subject: [PATCH] fix fingerprint debug scripts (#33277) * fix fp debugging * fix these old-commit-hash: 90ce7781f4caf0d0469d8897259612e4117e3a48 --- selfdrive/car/disable_ecu.py | 4 +++- selfdrive/car/ecu_addrs.py | 5 +++-- selfdrive/car/fw_versions.py | 7 ++++--- selfdrive/car/vin.py | 4 +++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/selfdrive/car/disable_ecu.py b/selfdrive/car/disable_ecu.py index bbf5b4c9f..e38a21568 100755 --- a/selfdrive/car/disable_ecu.py +++ b/selfdrive/car/disable_ecu.py @@ -40,10 +40,12 @@ def disable_ecu(can_recv, can_send, bus=0, addr=0x7d0, sub_addr=None, com_cont_r if __name__ == "__main__": import time import cereal.messaging as messaging + from openpilot.selfdrive.car.card import can_comm_callbacks sendcan = messaging.pub_sock('sendcan') logcan = messaging.sub_sock('can') + can_callbacks = can_comm_callbacks(logcan, sendcan) time.sleep(1) # honda bosch radar disable - disabled = disable_ecu(logcan, sendcan, bus=1, addr=0x18DAB0F1, com_cont_req=b'\x28\x83\x03', timeout=0.5, debug=False) + disabled = disable_ecu(*can_callbacks, bus=1, addr=0x18DAB0F1, com_cont_req=b'\x28\x83\x03', timeout=0.5, debug=False) print(f"disabled: {disabled}") diff --git a/selfdrive/car/ecu_addrs.py b/selfdrive/car/ecu_addrs.py index 336d0d554..1e7905dac 100755 --- a/selfdrive/car/ecu_addrs.py +++ b/selfdrive/car/ecu_addrs.py @@ -62,7 +62,7 @@ if __name__ == "__main__": import argparse import cereal.messaging as messaging from openpilot.common.params import Params - from openpilot.selfdrive.car.card import obd_callback + from openpilot.selfdrive.car.card import can_comm_callbacks, obd_callback parser = argparse.ArgumentParser(description='Get addresses of all ECUs') parser.add_argument('--debug', action='store_true') @@ -73,6 +73,7 @@ if __name__ == "__main__": logcan = messaging.sub_sock('can') sendcan = messaging.pub_sock('sendcan') + can_callbacks = can_comm_callbacks(logcan, sendcan) # Set up params for pandad params = Params() @@ -84,7 +85,7 @@ if __name__ == "__main__": obd_callback(params)(not args.no_obd) print("Getting ECU addresses ...") - ecu_addrs = _get_all_ecu_addrs(logcan, sendcan, args.bus, args.timeout, debug=args.debug) + ecu_addrs = _get_all_ecu_addrs(*can_callbacks, args.bus, args.timeout, debug=args.debug) print() print("Found ECUs on rx addresses:") diff --git a/selfdrive/car/fw_versions.py b/selfdrive/car/fw_versions.py index 7cee14bfb..0fef6456d 100755 --- a/selfdrive/car/fw_versions.py +++ b/selfdrive/car/fw_versions.py @@ -335,7 +335,7 @@ if __name__ == "__main__": import cereal.messaging as messaging from openpilot.common.params import Params from openpilot.selfdrive.car.vin import get_vin - from openpilot.selfdrive.car.card import obd_callback + from openpilot.selfdrive.car.card import can_comm_callbacks, obd_callback parser = argparse.ArgumentParser(description='Get firmware version of ECUs') parser.add_argument('--scan', action='store_true') @@ -346,6 +346,7 @@ if __name__ == "__main__": logcan = messaging.sub_sock('can') pandaStates_sock = messaging.sub_sock('pandaStates') sendcan = messaging.pub_sock('sendcan') + can_callbacks = can_comm_callbacks(logcan, sendcan) # Set up params for pandad params = Params() @@ -370,13 +371,13 @@ if __name__ == "__main__": t = time.time() print("Getting vin...") set_obd_multiplexing(True) - vin_rx_addr, vin_rx_bus, vin = get_vin(logcan, sendcan, (0, 1), debug=args.debug) + vin_rx_addr, vin_rx_bus, vin = get_vin(*can_callbacks, (0, 1), debug=args.debug) print(f'RX: {hex(vin_rx_addr)}, BUS: {vin_rx_bus}, VIN: {vin}') print(f"Getting VIN took {time.time() - t:.3f} s") print() t = time.time() - fw_vers = get_fw_versions(logcan, sendcan, set_obd_multiplexing, query_brand=args.brand, extra=extra, num_pandas=num_pandas, debug=args.debug, progress=True) + fw_vers = get_fw_versions(*can_callbacks, set_obd_multiplexing, query_brand=args.brand, extra=extra, num_pandas=num_pandas, debug=args.debug, progress=True) _, candidates = match_fw_to_car(fw_vers, vin) print() diff --git a/selfdrive/car/vin.py b/selfdrive/car/vin.py index 9a667f3ce..c42f984dc 100755 --- a/selfdrive/car/vin.py +++ b/selfdrive/car/vin.py @@ -63,6 +63,7 @@ if __name__ == "__main__": import argparse import time import cereal.messaging as messaging + from openpilot.selfdrive.car.card import can_comm_callbacks parser = argparse.ArgumentParser(description='Get VIN of the car') parser.add_argument('--debug', action='store_true') @@ -73,7 +74,8 @@ if __name__ == "__main__": sendcan = messaging.pub_sock('sendcan') logcan = messaging.sub_sock('can') + can_callbacks = can_comm_callbacks(logcan, sendcan) time.sleep(1) - vin_rx_addr, vin_rx_bus, vin = get_vin(logcan, sendcan, (args.bus,), args.timeout, args.retry, debug=args.debug) + vin_rx_addr, vin_rx_bus, vin = get_vin(*can_callbacks, (args.bus,), args.timeout, args.retry, debug=args.debug) print(f'RX: {hex(vin_rx_addr)}, BUS: {vin_rx_bus}, VIN: {vin}')