diff --git a/cereal b/cereal index 7870a1123d..bc999518e7 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit 7870a1123d4e8dfe5c39e86224c2f851382f3fed +Subproject commit bc999518e73c2b04fee3b8207b3c28a8644233ea diff --git a/selfdrive/car/fw_versions.py b/selfdrive/car/fw_versions.py index ee2c0f31d4..9c6f6e44f0 100755 --- a/selfdrive/car/fw_versions.py +++ b/selfdrive/car/fw_versions.py @@ -452,7 +452,8 @@ def get_fw_versions(logcan, sendcan, query_brand=None, extra=None, timeout=0.1, addrs.insert(0, parallel_addrs) - fw_versions = {} + # Get versions and build capnp list to put into CarParams + car_fw = [] requests = [r for r in REQUESTS if query_brand is None or r.brand == query_brand] for addr in tqdm(addrs, disable=not progress): for addr_chunk in chunks(addr): @@ -463,26 +464,23 @@ 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()}) - except Exception: - cloudlog.warning(f"FW query exception: {traceback.format_exc()}") + for (addr, rx_addr), version in query.get_data(timeout).items(): + f = car.CarParams.CarFw.new_message() - # Build capnp list to put into CarParams - car_fw = [] - for (brand, addr), (version, request) in fw_versions.items(): - f = car.CarParams.CarFw.new_message() + f.ecu = ecu_types[(r.brand, addr[0], addr[1])] + f.fwVersion = version + f.address = addr[0] + f.responseAddress = rx_addr + f.request = r.request + f.brand = r.brand + f.bus = r.bus - f.ecu = ecu_types[(brand, addr[0], addr[1])] - f.fwVersion = version - f.address = addr[0] - f.responseAddress = uds.get_rx_addr_for_tx_addr(addr[0], request.rx_offset) - f.request = request.request - f.brand = brand + if addr[1] is not None: + f.subAddress = addr[1] - if addr[1] is not None: - f.subAddress = addr[1] - - car_fw.append(f) + car_fw.append(f) + except Exception: + cloudlog.warning(f"FW query exception: {traceback.format_exc()}") return car_fw @@ -531,7 +529,7 @@ if __name__ == "__main__": padding = max([len(fw.brand) for fw in fw_vers] or [0]) for version in fw_vers: subaddr = None if version.subAddress == 0 else hex(version.subAddress) - print(f" Brand: {version.brand:{padding}} - (Ecu.{version.ecu}, {hex(version.address)}, {subaddr}): [{version.fwVersion}]") + print(f" Brand: {version.brand:{padding}}, bus: {version.bus} - (Ecu.{version.ecu}, {hex(version.address)}, {subaddr}): [{version.fwVersion}]") print("}") print() diff --git a/selfdrive/debug/test_fw_query_on_routes.py b/selfdrive/debug/test_fw_query_on_routes.py index 191411f45a..0cc674cfc8 100755 --- a/selfdrive/debug/test_fw_query_on_routes.py +++ b/selfdrive/debug/test_fw_query_on_routes.py @@ -115,7 +115,7 @@ if __name__ == "__main__": padding = max([len(fw.brand or UNKNOWN_BRAND) for fw in car_fw]) for version in sorted(car_fw, key=lambda fw: fw.brand): subaddr = None if version.subAddress == 0 else hex(version.subAddress) - print(f" Brand: {version.brand or UNKNOWN_BRAND:{padding}} - (Ecu.{version.ecu}, {hex(version.address)}, {subaddr}): [{version.fwVersion}],") + print(f" Brand: {version.brand or UNKNOWN_BRAND:{padding}}, bus: {version.bus} - (Ecu.{version.ecu}, {hex(version.address)}, {subaddr}): [{version.fwVersion}],") print("Mismatches") found = False