mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-09 07:32:06 +08:00
IsoTpParallelQuery: don't return rx_addr (#25934)
* revert isotpparallelquery returning rx addr for functional special case * we don't really use the tx addr (and soon won't make sense with fun querying) old-commit-hash: 4d7f4b4c9db739c85989797b750226b0ec217f71
This commit is contained in:
@@ -97,7 +97,7 @@ def fingerprint(logcan, sendcan):
|
||||
car_fw = list(cached_params.carFw)
|
||||
else:
|
||||
cloudlog.warning("Getting VIN & FW versions")
|
||||
_, vin_rx_addr, 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)
|
||||
|
||||
|
||||
@@ -253,13 +253,13 @@ 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)
|
||||
for (addr, rx_addr), version in query.get_data(timeout).items():
|
||||
for (tx_addr, sub_addr), version in query.get_data(timeout).items():
|
||||
f = car.CarParams.CarFw.new_message()
|
||||
|
||||
f.ecu = ecu_types.get((brand, addr[0], addr[1]), Ecu.unknown)
|
||||
f.ecu = ecu_types.get((brand, tx_addr, sub_addr), Ecu.unknown)
|
||||
f.fwVersion = version
|
||||
f.address = addr[0]
|
||||
f.responseAddress = rx_addr
|
||||
f.responseAddress = uds.get_rx_addr_for_tx_addr(tx_addr, r.rx_offset)
|
||||
f.request = r.request
|
||||
f.brand = brand
|
||||
f.bus = r.bus
|
||||
@@ -303,8 +303,8 @@ if __name__ == "__main__":
|
||||
|
||||
t = time.time()
|
||||
print("Getting 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}')
|
||||
vin_rx_addr, vin = get_vin(logcan, sendcan, 1, retry=10, debug=args.debug)
|
||||
print(f'RX: {hex(vin_rx_addr)}, VIN: {vin}')
|
||||
print(f"Getting VIN took {time.time() - t:.3f} s")
|
||||
print()
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ class IsoTpParallelQuery:
|
||||
msg.send(self.request[counter + 1])
|
||||
request_counter[tx_addr] += 1
|
||||
else:
|
||||
results[(tx_addr, msg._can_client.rx_addr)] = dat[len(expected_response):]
|
||||
results[tx_addr] = dat[len(expected_response):]
|
||||
request_done[tx_addr] = True
|
||||
else:
|
||||
error_code = dat[2] if len(dat) > 2 else -1
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import re
|
||||
|
||||
import cereal.messaging as messaging
|
||||
from panda.python.uds import get_rx_addr_for_tx_addr
|
||||
from selfdrive.car.isotp_parallel_query import IsoTpParallelQuery
|
||||
from selfdrive.car.fw_query_definitions import StdQueries
|
||||
from system.swaglog import cloudlog
|
||||
@@ -20,18 +21,18 @@ def get_vin(logcan, sendcan, bus, timeout=0.1, retry=5, debug=False):
|
||||
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 (addr, rx_addr), vin in query.get_data(timeout).items():
|
||||
for (tx_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], rx_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")
|
||||
|
||||
return 0, 0, VIN_UNKNOWN
|
||||
return 0, VIN_UNKNOWN
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@@ -49,5 +50,5 @@ if __name__ == "__main__":
|
||||
logcan = messaging.sub_sock('can')
|
||||
time.sleep(1)
|
||||
|
||||
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}')
|
||||
vin_rx_addr, vin = get_vin(logcan, sendcan, args.bus, args.timeout, args.retry, debug=args.debug)
|
||||
print(f'RX: {hex(vin_rx_addr)}, VIN: {vin}')
|
||||
|
||||
Reference in New Issue
Block a user