diff --git a/selfdrive/car/fw_versions.py b/selfdrive/car/fw_versions.py index bc5a4a326d..3f72311cdf 100755 --- a/selfdrive/car/fw_versions.py +++ b/selfdrive/car/fw_versions.py @@ -86,15 +86,11 @@ def match_fw_to_car_fuzzy(fw_versions_dict, config, log=True, exclude=None): for addr, versions in fw_versions_dict.items(): ecu_key = (addr[0], addr[1]) for version in versions: - # Fall back to matching with full FW versions if brand does not implement platform codes - candidates = set() - # TODO: we might want to try both, the only reason we'd want to replace exact with platform codes is if - # previous function was giving us false positives, which it isn't. we lose fuzzy FP for a lot of platforms - # with just platform codes on two ECUs... - if config.fuzzy_get_platform_codes is None: - # All cars that have this FW response on the specified address - candidates = all_fw_versions[(*ecu_key, version)] - else: + # All cars that have this FW response on the specified address + candidates = all_fw_versions[(*ecu_key, version)] + + # If no exact FW matches, try brand-specific fuzzy fingerprinting + if len(candidates) != 1 and config.fuzzy_get_platform_codes is not None: # Returns one or none, all cars that have this platform code for platform_code in config.fuzzy_get_platform_codes([version]): candidates = all_platform_codes[(*ecu_key, platform_code)] diff --git a/selfdrive/car/hyundai/tests/test_hyundai.py b/selfdrive/car/hyundai/tests/test_hyundai.py index 6423570fe9..b9d3a1f527 100755 --- a/selfdrive/car/hyundai/tests/test_hyundai.py +++ b/selfdrive/car/hyundai/tests/test_hyundai.py @@ -121,7 +121,12 @@ class TestHyundaiFingerprint(TestFwFingerprintBase): for platform, fw_by_addr in FW_VERSIONS.items(): car_fw = [] for ecu, fw_versions in fw_by_addr.items(): + # Only test fuzzy ECUs so excluded platforms for platforms codes are accurate + # We can still fuzzy match via exact FW matches ecu_name, addr, sub_addr = ecu + if ecu_name not in FW_QUERY_CONFIG.fuzzy_ecus: + continue + for fw in fw_versions: car_fw.append({"ecu": ecu_name, "fwVersion": fw, 'brand': 'hyundai', "address": addr, "subAddress": 0 if sub_addr is None else sub_addr})