vin and ecu_addrs: add more argparse options (#25913)

* add bus options

* use debug

* add timeout and try

* fix

* don't need keywords

* log this too

* fix
old-commit-hash: 0ec8546042
taco
Shane Smiskol 3 years ago committed by GitHub
parent 10bc36ae58
commit c3fb4dda1b
  1. 7
      selfdrive/car/ecu_addrs.py
  2. 12
      selfdrive/car/vin.py

@ -1,7 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import capnp import capnp
import time import time
import traceback
from typing import Optional, Set, Tuple from typing import Optional, Set, Tuple
import cereal.messaging as messaging 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)}") print(f"Duplicate ECU address: {hex(msg.address)}")
ecu_responses.add((msg.address, subaddr, msg.src)) ecu_responses.add((msg.address, subaddr, msg.src))
except Exception: except Exception:
cloudlog.warning(f"ECU addr scan exception: {traceback.format_exc()}") cloudlog.exception("ECU addr scan exception")
return ecu_responses return ecu_responses
@ -71,6 +70,8 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Get addresses of all ECUs') parser = argparse.ArgumentParser(description='Get addresses of all ECUs')
parser.add_argument('--debug', action='store_true') 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() args = parser.parse_args()
logcan = messaging.sub_sock('can') logcan = messaging.sub_sock('can')
@ -79,7 +80,7 @@ if __name__ == "__main__":
time.sleep(1.0) time.sleep(1.0)
print("Getting ECU addresses ...") 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()
print("Found ECUs on addresses:") print("Found ECUs on addresses:")

@ -35,9 +35,19 @@ def get_vin(logcan, sendcan, bus, timeout=0.1, retry=5, debug=False):
if __name__ == "__main__": if __name__ == "__main__":
import argparse
import time 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') sendcan = messaging.pub_sock('sendcan')
logcan = messaging.sub_sock('can') logcan = messaging.sub_sock('can')
time.sleep(1) 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}') print(f'TX: {hex(addr)}, RX: {hex(vin_rx_addr)}, VIN: {vin}')

Loading…
Cancel
Save