mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-24 07:22:04 +08:00
VIN query: switch to functional address (#25933)
* stash * go in defined order * \n feels cleaner
This commit is contained in:
+13
-8
@@ -2,7 +2,7 @@
|
||||
import re
|
||||
|
||||
import cereal.messaging as messaging
|
||||
from panda.python.uds import get_rx_addr_for_tx_addr
|
||||
from panda.python.uds import get_rx_addr_for_tx_addr, FUNCTIONAL_ADDRS
|
||||
from selfdrive.car.isotp_parallel_query import IsoTpParallelQuery
|
||||
from selfdrive.car.fw_query_definitions import StdQueries
|
||||
from system.swaglog import cloudlog
|
||||
@@ -16,18 +16,23 @@ def is_valid_vin(vin: str):
|
||||
|
||||
|
||||
def get_vin(logcan, sendcan, bus, timeout=0.1, retry=5, debug=False):
|
||||
addrs = [0x7e0, 0x7e2, 0x18da10f1, 0x18da0ef1] # engine, VMCU, 29-bit engine, PGM-FI
|
||||
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 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, ], debug=debug)
|
||||
for (tx_addr, _), vin in query.get_data(timeout).items():
|
||||
query = IsoTpParallelQuery(sendcan, logcan, bus, addrs, [request, ], [response, ], functional_addrs=FUNCTIONAL_ADDRS, debug=debug)
|
||||
results = query.get_data(timeout)
|
||||
|
||||
# Honda Bosch response starts with a length, trim to correct length
|
||||
if vin.startswith(b'\x11'):
|
||||
vin = vin[1:18]
|
||||
for addr in valid_vin_addrs:
|
||||
vin = results.get((addr, None))
|
||||
if vin is not None:
|
||||
# Honda Bosch response starts with a length, trim to correct length
|
||||
if vin.startswith(b'\x11'):
|
||||
vin = vin[1:18]
|
||||
|
||||
return get_rx_addr_for_tx_addr(addr), vin.decode()
|
||||
|
||||
return get_rx_addr_for_tx_addr(tx_addr), vin.decode()
|
||||
cloudlog.error(f"vin query retry ({i+1}) ...")
|
||||
except Exception:
|
||||
cloudlog.exception("VIN query exception")
|
||||
|
||||
Reference in New Issue
Block a user