diff --git a/selfdrive/car/fw_versions.py b/selfdrive/car/fw_versions.py index ca75ed62e5..23e3e9870a 100755 --- a/selfdrive/car/fw_versions.py +++ b/selfdrive/car/fw_versions.py @@ -75,7 +75,7 @@ def match_fw_to_car_fuzzy(fw_versions_dict, log=True, exclude=None): for f in fws: all_fw_versions[(addr[1], addr[2], f)].append(candidate) - matched_ecus = set() + matched_ecus = list() candidate = None for addr, versions in fw_versions_dict.items(): ecu_key = (addr[0], addr[1]) @@ -84,7 +84,7 @@ def match_fw_to_car_fuzzy(fw_versions_dict, log=True, exclude=None): candidates = all_fw_versions[(*ecu_key, version)] if len(candidates) == 1: - matched_ecus.add(ecu_key) + matched_ecus.append(ecu_key) if candidate is None: candidate = candidates[0] # We uniquely matched two different cars. No fuzzy match possible diff --git a/selfdrive/car/tests/test_fw_fingerprint.py b/selfdrive/car/tests/test_fw_fingerprint.py index 2eef7e4c24..144f743850 100755 --- a/selfdrive/car/tests/test_fw_fingerprint.py +++ b/selfdrive/car/tests/test_fw_fingerprint.py @@ -51,21 +51,24 @@ class TestFwFingerprint(unittest.TestCase): def test_fuzzy_match(self, brand, car_model, ecus): # TODO: speed up fuzzy matching and test more CP = car.CarParams.new_message() + # if car_model != "HYUNDAI IONIQ ELECTRIC LIMITED 2019": + # raise unittest.SkipTest for _ in range(1): fw = [] for ecu, fw_versions in ecus.items(): if not len(fw_versions): raise unittest.SkipTest("Car model has no FW versions") ecu_name, addr, sub_addr = ecu - fw.append({"ecu": ecu_name, "fwVersion": random.choice(fw_versions), 'brand': brand, - "address": addr, "subAddress": 0 if sub_addr is None else sub_addr}) + fw.extend([{"ecu": ecu_name, "fwVersion": random.choice(fw_versions), 'brand': brand, + "address": addr, "subAddress": 0 if sub_addr is None else sub_addr}]*2) CP.carFw = fw _, matches = match_fw_to_car(CP.carFw, allow_exact=False, log=False) # Assert no match if there are not enough valid ECUs valid_ecus = [(f['address'], f['subAddress']) for f in fw if f['ecu'] not in FUZZY_EXCLUDE_ECUS] + print(valid_ecus, matches) if len(set(valid_ecus)) < 2: - self.assertEqual(len(matches), 0) + self.assertEqual(len(matches), 0, valid_ecus) # There won't always be a match due to shared FW, but if there is it should be correct elif len(matches): self.assertFingerprints(matches, car_model)