diff --git a/selfdrive/car/fw_versions.py b/selfdrive/car/fw_versions.py index 6da282d7ec..4f51c8e1a3 100755 --- a/selfdrive/car/fw_versions.py +++ b/selfdrive/car/fw_versions.py @@ -72,6 +72,7 @@ def match_fw_to_car_fuzzy(fw_versions_dict, log=True, exclude=None): all_fw_versions[(addr[1], addr[2], f)].append(candidate) matched_ecus = set() + match_count = 0 candidate = None for addr, versions in fw_versions_dict.items(): for version in versions: @@ -81,12 +82,14 @@ def match_fw_to_car_fuzzy(fw_versions_dict, log=True, exclude=None): if len(candidates) == 1: matched_ecus.add(ecu_key) + match_count += 1 if candidate is None: candidate = candidates[0] # We uniquely matched two different cars. No fuzzy match possible elif candidate != candidates[0]: return set() + print(candidate, match_count, len(matched_ecus), match_count == len(matched_ecus)) if len(matched_ecus) >= 2: if log: cloudlog.error(f"Fingerprinted {candidate} using fuzzy match. {len(matched_ecus)} matching ECUs") diff --git a/selfdrive/debug/internal/fuzz_fw_fingerprint.py b/selfdrive/debug/internal/fuzz_fw_fingerprint.py index 81dca9af77..0c5743618a 100755 --- a/selfdrive/debug/internal/fuzz_fw_fingerprint.py +++ b/selfdrive/debug/internal/fuzz_fw_fingerprint.py @@ -24,16 +24,13 @@ if __name__ == "__main__": wrong_match = 0 confusions = defaultdict(set) - for _ in tqdm(range(1)): + for _ in tqdm(range(10)): for candidate, fws in FWS.items(): fw_dict = {} for (tp, addr, subaddr), fw_list in fws.items(): fw_dict[(addr, subaddr)] = [random.choice(fw_list)] - print(f"Testing {candidate}") - matches = match_fw_to_car_fuzzy(fw_dict, log=False) - print(matches) - print() + matches = match_fw_to_car_fuzzy(fw_dict, log=False, exclude=candidate) total += 1 if len(matches) == 1: