From bfc4d72402a881bb8357cc3b5a92ca9a20abdaa7 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 30 Sep 2022 16:01:22 -0700 Subject: [PATCH] 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 --- selfdrive/car/car_helpers.py | 2 +- selfdrive/car/fw_versions.py | 10 +++++----- selfdrive/car/isotp_parallel_query.py | 2 +- selfdrive/car/vin.py | 11 ++++++----- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/selfdrive/car/car_helpers.py b/selfdrive/car/car_helpers.py index 4f098fadb5..273364071b 100644 --- a/selfdrive/car/car_helpers.py +++ b/selfdrive/car/car_helpers.py @@ -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) diff --git a/selfdrive/car/fw_versions.py b/selfdrive/car/fw_versions.py index bf88e77db5..390deab52e 100755 --- a/selfdrive/car/fw_versions.py +++ b/selfdrive/car/fw_versions.py @@ -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() diff --git a/selfdrive/car/isotp_parallel_query.py b/selfdrive/car/isotp_parallel_query.py index d3e4972bd8..94c8d052b3 100644 --- a/selfdrive/car/isotp_parallel_query.py +++ b/selfdrive/car/isotp_parallel_query.py @@ -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 diff --git a/selfdrive/car/vin.py b/selfdrive/car/vin.py index 860f3b0fa2..2974cebada 100755 --- a/selfdrive/car/vin.py +++ b/selfdrive/car/vin.py @@ -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}')