diff --git a/selfdrive/car/ecu_addrs.py b/selfdrive/car/ecu_addrs.py index 267701509a..9f6ace2b5f 100755 --- a/selfdrive/car/ecu_addrs.py +++ b/selfdrive/car/ecu_addrs.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 import capnp import time -import traceback from typing import Optional, Set, Tuple import cereal.messaging as messaging @@ -62,7 +61,7 @@ def get_ecu_addrs(logcan: messaging.SubSocket, sendcan: messaging.PubSocket, que print(f"Duplicate ECU address: {hex(msg.address)}") ecu_responses.add((msg.address, subaddr, msg.src)) except Exception: - cloudlog.warning(f"ECU addr scan exception: {traceback.format_exc()}") + cloudlog.exception("ECU addr scan exception") return ecu_responses @@ -71,6 +70,8 @@ if __name__ == "__main__": parser = argparse.ArgumentParser(description='Get addresses of all ECUs') parser.add_argument('--debug', action='store_true') + parser.add_argument('--bus', type=int, default=1) + parser.add_argument('--timeout', type=float, default=1.0) args = parser.parse_args() logcan = messaging.sub_sock('can') @@ -79,7 +80,7 @@ if __name__ == "__main__": time.sleep(1.0) print("Getting ECU addresses ...") - ecu_addrs = get_all_ecu_addrs(logcan, sendcan, 1, debug=args.debug) + ecu_addrs = get_all_ecu_addrs(logcan, sendcan, args.bus, args.timeout, debug=args.debug) print() print("Found ECUs on addresses:") diff --git a/selfdrive/car/vin.py b/selfdrive/car/vin.py index 909322f9c9..860f3b0fa2 100755 --- a/selfdrive/car/vin.py +++ b/selfdrive/car/vin.py @@ -35,9 +35,19 @@ def get_vin(logcan, sendcan, bus, timeout=0.1, retry=5, debug=False): if __name__ == "__main__": + import argparse import time + + parser = argparse.ArgumentParser(description='Get VIN of the car') + parser.add_argument('--debug', action='store_true') + parser.add_argument('--bus', type=int, default=1) + parser.add_argument('--timeout', type=float, default=0.1) + parser.add_argument('--retry', type=int, default=5) + args = parser.parse_args() + sendcan = messaging.pub_sock('sendcan') logcan = messaging.sub_sock('can') time.sleep(1) - addr, vin_rx_addr, vin = get_vin(logcan, sendcan, 1, debug=False) + + addr, vin_rx_addr, vin = get_vin(logcan, sendcan, args.bus, args.timeout, args.retry, debug=args.debug) print(f'TX: {hex(addr)}, RX: {hex(vin_rx_addr)}, VIN: {vin}')