diff --git a/selfdrive/car/car_helpers.py b/selfdrive/car/car_helpers.py index 7f83732153..690072cc4d 100644 --- a/selfdrive/car/car_helpers.py +++ b/selfdrive/car/car_helpers.py @@ -79,7 +79,7 @@ interfaces = load_interfaces(interface_names) def fingerprint(logcan, sendcan): fixed_fingerprint = os.environ.get('FINGERPRINT', "") skip_fw_query = os.environ.get('SKIP_FW_QUERY', False) - ecu_responses = set() + ecu_rx_addrs = set() if not fixed_fingerprint and not skip_fw_query: # Vin query only reliably works thorugh OBDII @@ -98,7 +98,7 @@ def fingerprint(logcan, sendcan): else: cloudlog.warning("Getting VIN & FW versions") _, vin = get_vin(logcan, sendcan, bus) - ecu_responses = get_present_ecus(logcan, sendcan) + ecu_rx_addrs = get_present_ecus(logcan, sendcan) car_fw = get_fw_versions(logcan, sendcan) exact_fw_match, fw_candidates = match_fw_to_car(car_fw) @@ -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=ecu_responses, error=True) + fw_count=len(car_fw), ecu_responses=list(ecu_rx_addrs), error=True) return car_fingerprint, finger, vin, car_fw, source, exact_match diff --git a/selfdrive/car/fw_versions.py b/selfdrive/car/fw_versions.py index 03dcece10c..c51d120166 100755 --- a/selfdrive/car/fw_versions.py +++ b/selfdrive/car/fw_versions.py @@ -290,24 +290,21 @@ def match_fw_to_car(fw_versions, allow_fuzzy=True): versions = get_interface_attr('FW_VERSIONS', ignore_none=True) # Try exact matching first - exact_matches = [True] + exact_matches = [(True, match_fw_to_car_exact)] if allow_fuzzy: - exact_matches.append(False) + exact_matches.append((False, match_fw_to_car_fuzzy)) - for exact_match in exact_matches: + for exact_match, match_func in exact_matches: # For each brand, attempt to fingerprint using FW returned from its queries + matches = set() for brand in versions.keys(): fw_versions_dict = build_fw_dict(fw_versions, filter_brand=brand) + matches |= match_func(fw_versions_dict) - if exact_match: - matches = match_fw_to_car_exact(fw_versions_dict) - else: - matches = match_fw_to_car_fuzzy(fw_versions_dict) + if len(matches): + return exact_match, matches - if len(matches) == 1: - return exact_match, matches - - return True, [] + return True, set() def get_present_ecus(logcan, sendcan): @@ -448,9 +445,10 @@ if __name__ == "__main__": print() print("Found FW versions") print("{") + padding = max([len(fw.brand) for fw in fw_vers]) for version in fw_vers: subaddr = None if version.subAddress == 0 else hex(version.subAddress) - print(f" (Ecu.{version.ecu}, {hex(version.address)}, {subaddr}): [{version.fwVersion}]") + print(f" Brand: {version.brand:{padding}} - (Ecu.{version.ecu}, {hex(version.address)}, {subaddr}): [{version.fwVersion}]") print("}") print()