vin: fix retry logging (#31225)

* retry should really be outside inner query loop

* just req

* nls

* bump

* rmnl

* useful to have

* is it though
pull/31226/head
Shane Smiskol 1 year ago committed by GitHub
parent 4243e9322a
commit 3a0033e81e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      selfdrive/car/fw_query_definitions.py
  2. 13
      selfdrive/car/vin.py

@ -14,6 +14,9 @@ EcuAddrSubAddr = Tuple[int, int, Optional[int]]
LiveFwVersions = Dict[AddrType, Set[bytes]]
OfflineFwVersions = Dict[str, Dict[EcuAddrSubAddr, List[bytes]]]
STANDARD_VIN_ADDRS = [0x7e0, 0x7e2, 0x18da10f1, 0x18da0ef1] # engine, VMCU, 29-bit engine, PGM-FI
def p16(val):
return struct.pack("!H", val)

@ -4,7 +4,7 @@ import re
import cereal.messaging as messaging
from panda.python.uds import get_rx_addr_for_tx_addr, FUNCTIONAL_ADDRS
from openpilot.selfdrive.car.isotp_parallel_query import IsoTpParallelQuery
from openpilot.selfdrive.car.fw_query_definitions import StdQueries
from openpilot.selfdrive.car.fw_query_definitions import STANDARD_VIN_ADDRS, StdQueries
from openpilot.common.swaglog import cloudlog
VIN_UNKNOWN = "0" * 17
@ -16,16 +16,14 @@ def is_valid_vin(vin: str):
def get_vin(logcan, sendcan, buses, timeout=0.1, retry=3, debug=False):
addrs = list(range(0x7e0, 0x7e8)) + list(range(0x18DA00F1, 0x18DB00F1, 0x100)) # addrs to process/wait for
valid_vin_addrs = [0x7e0, 0x7e2, 0x18da10f1, 0x18da0ef1] # engine, VMCU, 29-bit engine, PGM-FI
for i in range(retry):
for bus in buses:
for request, response in ((StdQueries.UDS_VIN_REQUEST, StdQueries.UDS_VIN_RESPONSE), (StdQueries.OBD_VIN_REQUEST, StdQueries.OBD_VIN_RESPONSE)):
try:
query = IsoTpParallelQuery(sendcan, logcan, bus, addrs, [request, ], [response, ], functional_addrs=FUNCTIONAL_ADDRS, debug=debug)
query = IsoTpParallelQuery(sendcan, logcan, bus, STANDARD_VIN_ADDRS, [request, ], [response, ], functional_addrs=FUNCTIONAL_ADDRS, debug=debug)
results = query.get_data(timeout)
for addr in valid_vin_addrs:
for addr in STANDARD_VIN_ADDRS:
vin = results.get((addr, None))
if vin is not None:
# Ford pads with null bytes
@ -36,12 +34,13 @@ def get_vin(logcan, sendcan, buses, timeout=0.1, retry=3, debug=False):
if vin.startswith(b'\x11'):
vin = vin[1:18]
cloudlog.warning(f"got vin with {request=}")
return get_rx_addr_for_tx_addr(addr), bus, vin.decode()
cloudlog.error(f"vin query retry ({i+1}) ...")
except Exception:
cloudlog.exception("VIN query exception")
cloudlog.error(f"vin query retry ({i+1}) ...")
return -1, -1, VIN_UNKNOWN

Loading…
Cancel
Save