mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-04 21:12:07 +08:00
Log VIN response address (#25148)
* log vin rx addr * clean up old-commit-hash: 3a8f17111c3439cb22eb627aec805898d9d9a41a
This commit is contained in:
@@ -93,17 +93,17 @@ def fingerprint(logcan, sendcan):
|
||||
|
||||
if cached_params is not None and len(cached_params.carFw) > 0 and cached_params.carVin is not VIN_UNKNOWN:
|
||||
cloudlog.warning("Using cached CarParams")
|
||||
vin = cached_params.carVin
|
||||
vin, vin_rx_addr = cached_params.carVin, 0
|
||||
car_fw = list(cached_params.carFw)
|
||||
else:
|
||||
cloudlog.warning("Getting VIN & FW versions")
|
||||
_, vin = get_vin(logcan, sendcan, bus)
|
||||
_, vin_rx_addr, vin = get_vin(logcan, sendcan, bus)
|
||||
ecu_rx_addrs = get_present_ecus(logcan, sendcan)
|
||||
car_fw = get_fw_versions_ordered(logcan, sendcan, ecu_rx_addrs)
|
||||
|
||||
exact_fw_match, fw_candidates = match_fw_to_car(car_fw)
|
||||
else:
|
||||
vin = VIN_UNKNOWN
|
||||
vin, vin_rx_addr = VIN_UNKNOWN, 0
|
||||
exact_fw_match, fw_candidates, car_fw = True, set(), []
|
||||
|
||||
if len(vin) != 17:
|
||||
@@ -166,7 +166,7 @@ def fingerprint(logcan, sendcan):
|
||||
source = car.CarParams.FingerprintSource.fixed
|
||||
|
||||
cloudlog.event("fingerprinted", car_fingerprint=car_fingerprint, source=source, fuzzy=not exact_match,
|
||||
fw_count=len(car_fw), ecu_responses=list(ecu_rx_addrs), error=True)
|
||||
fw_count=len(car_fw), ecu_responses=list(ecu_rx_addrs), vin_rx_addr=vin_rx_addr, error=True)
|
||||
return car_fingerprint, finger, vin, car_fw, source, exact_match
|
||||
|
||||
|
||||
|
||||
@@ -444,7 +444,7 @@ def get_fw_versions(logcan, sendcan, query_brand=None, extra=None, timeout=0.1,
|
||||
|
||||
if addrs:
|
||||
query = IsoTpParallelQuery(sendcan, logcan, r.bus, addrs, r.request, r.response, r.rx_offset, debug=debug)
|
||||
fw_versions.update({(r.brand, addr): (version, r) for addr, version in query.get_data(timeout).items()})
|
||||
fw_versions.update({(r.brand, addr): (version, r) for (addr, _), version in query.get_data(timeout).items()})
|
||||
except Exception:
|
||||
cloudlog.warning(f"FW query exception: {traceback.format_exc()}")
|
||||
|
||||
@@ -497,8 +497,8 @@ if __name__ == "__main__":
|
||||
|
||||
t = time.time()
|
||||
print("Getting vin...")
|
||||
addr, vin = get_vin(logcan, sendcan, 1, retry=10, debug=args.debug)
|
||||
print(f"VIN: {vin}")
|
||||
addr, vin_rx_addr, vin = get_vin(logcan, sendcan, 1, retry=10, debug=args.debug)
|
||||
print(f'TX: {hex(addr)}, RX: {hex(vin_rx_addr)}, VIN: {vin}')
|
||||
print(f"Getting VIN took {time.time() - t:.3f} s")
|
||||
print()
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ class IsoTpParallelQuery:
|
||||
msg.send(self.request[counter + 1])
|
||||
request_counter[tx_addr] += 1
|
||||
else:
|
||||
results[tx_addr] = dat[len(expected_response):]
|
||||
results[(tx_addr, msg._can_client.rx_addr)] = dat[len(expected_response):]
|
||||
request_done[tx_addr] = True
|
||||
else:
|
||||
error_code = dat[2] if len(dat) > 2 else -1
|
||||
|
||||
@@ -22,18 +22,18 @@ def get_vin(logcan, sendcan, bus, timeout=0.1, retry=5, debug=False):
|
||||
for request, response in ((UDS_VIN_REQUEST, UDS_VIN_RESPONSE), (OBD_VIN_REQUEST, OBD_VIN_RESPONSE)):
|
||||
try:
|
||||
query = IsoTpParallelQuery(sendcan, logcan, bus, FUNCTIONAL_ADDRS, [request, ], [response, ], functional_addr=True, debug=debug)
|
||||
for addr, vin in query.get_data(timeout).items():
|
||||
for (addr, rx_addr), vin in query.get_data(timeout).items():
|
||||
|
||||
# Honda Bosch response starts with a length, trim to correct length
|
||||
if vin.startswith(b'\x11'):
|
||||
vin = vin[1:18]
|
||||
|
||||
return addr[0], vin.decode()
|
||||
return addr[0], rx_addr, vin.decode()
|
||||
print(f"vin query retry ({i+1}) ...")
|
||||
except Exception:
|
||||
cloudlog.warning(f"VIN query exception: {traceback.format_exc()}")
|
||||
|
||||
return 0, VIN_UNKNOWN
|
||||
return 0, 0, VIN_UNKNOWN
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@@ -41,5 +41,5 @@ if __name__ == "__main__":
|
||||
sendcan = messaging.pub_sock('sendcan')
|
||||
logcan = messaging.sub_sock('can')
|
||||
time.sleep(1)
|
||||
addr, vin = get_vin(logcan, sendcan, 1, debug=False)
|
||||
print(hex(addr), vin)
|
||||
addr, vin_rx_addr, vin = get_vin(logcan, sendcan, 1, debug=False)
|
||||
print(f'TX: {hex(addr)}, RX: {hex(vin_rx_addr)}, VIN: {vin}')
|
||||
|
||||
@@ -16,7 +16,7 @@ def disable_ecu(ecu_addr, logcan, sendcan, bus, timeout=0.5, retry=5, debug=Fals
|
||||
try:
|
||||
# enter extended diagnostic session
|
||||
query = IsoTpParallelQuery(sendcan, logcan, bus, [ecu_addr], [EXT_DIAG_REQUEST], [EXT_DIAG_RESPONSE], debug=debug)
|
||||
for addr, dat in query.get_data(timeout).items(): # pylint: disable=unused-variable
|
||||
for _, _ in query.get_data(timeout).items(): # pylint: disable=unused-variable
|
||||
print("ecu communication control disable tx/rx ...")
|
||||
# communication control disable tx and rx
|
||||
query = IsoTpParallelQuery(sendcan, logcan, bus, [ecu_addr], [COM_CONT_REQUEST], [COM_CONT_RESPONSE], debug=debug)
|
||||
|
||||
Reference in New Issue
Block a user