diff --git a/selfdrive/car/toyota/tests/test_toyota.py b/selfdrive/car/toyota/tests/test_toyota.py index 49d88d642a..c29eae870d 100755 --- a/selfdrive/car/toyota/tests/test_toyota.py +++ b/selfdrive/car/toyota/tests/test_toyota.py @@ -5,7 +5,8 @@ import unittest from cereal import car from openpilot.selfdrive.car.fw_versions import build_fw_dict from openpilot.selfdrive.car.toyota.values import CAR, DBC, TSS2_CAR, ANGLE_CONTROL_CAR, RADAR_ACC_CAR, FW_VERSIONS, \ - FW_QUERY_CONFIG, PLATFORM_CODE_ECUS, get_platform_codes + FW_QUERY_CONFIG, PLATFORM_CODE_ECUS, FUZZY_EXCLUDED_PLATFORMS, \ + get_platform_codes Ecu = car.CarParams.Ecu ECU_NAME = {v: k for k, v in Ecu.schema.enumerants.items()} @@ -123,25 +124,6 @@ class TestToyotaFingerprint(unittest.TestCase): def test_fuzzy_excluded_platforms(self): # Asserts a list of platforms that will not fuzzy fingerprint with platform codes due to them being shared. - # This list can be shrunk as we combine platforms, detect features, and add the hybrid ECU. - # Note: this list is so small because other ECUs are not shared between hybrid & ICE, commonly the ABS - # TODO: should this be put into the fuzzy FP function as a blacklist? - excluded_platforms = { - CAR.LEXUS_ES_TSS2, - CAR.LEXUS_RX_TSS2, - CAR.CHR, - CAR.CHRH, - CAR.COROLLA_TSS2, - CAR.COROLLAH_TSS2, - CAR.RAV4_TSS2, - CAR.RAV4H_TSS2, - CAR.LEXUS_NX_TSS2, - CAR.LEXUS_NXH, - CAR.LEXUS_NXH_TSS2, - CAR.LEXUS_NX, - CAR.LEXUS_RXH_TSS2, - } - platforms_with_shared_codes = set() for platform, fw_by_addr in FW_VERSIONS.items(): car_fw = [] @@ -159,8 +141,8 @@ class TestToyotaFingerprint(unittest.TestCase): print('matches', platform, matches) platforms_with_shared_codes.add(platform) - print(len(platforms_with_shared_codes), len(excluded_platforms)) - self.assertEqual(platforms_with_shared_codes, excluded_platforms, (len(platforms_with_shared_codes), len(FW_VERSIONS))) + print(len(platforms_with_shared_codes), len(FUZZY_EXCLUDED_PLATFORMS)) + self.assertEqual(platforms_with_shared_codes, FUZZY_EXCLUDED_PLATFORMS, (len(platforms_with_shared_codes), len(FW_VERSIONS))) if __name__ == "__main__": diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index 89e2d0728f..a5e92f2d21 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -318,7 +318,7 @@ def match_fw_to_car_fuzzy(live_fw_versions, exclude_fw: dict[int, bytes] = None) if valid_expected_ecus.issubset(valid_found_ecus): candidates.add(candidate) - return candidates + return candidates - FUZZY_EXCLUDED_PLATFORMS # Regex patterns for parsing more general platform-specific identifiers from FW versions. @@ -348,6 +348,11 @@ FW_CHUNK_LEN = 16 # - eps: describes lateral API changes for the EPS, such as using LTA for lane keeping and rejecting LKA messages PLATFORM_CODE_ECUS = [Ecu.fwdCamera, Ecu.abs, Ecu.eps] +# These platforms have at least one platform code for all ECUs shared with another platform. +# This list can be shrunk as we combine platforms, detect features, and add the hybrid ECU +FUZZY_EXCLUDED_PLATFORMS = {CAR.LEXUS_ES_TSS2, CAR.LEXUS_RX_TSS2, CAR.CHR, CAR.CHRH, CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2, + CAR.RAV4_TSS2, CAR.RAV4H_TSS2, CAR.LEXUS_NX_TSS2, CAR.LEXUS_NXH, CAR.LEXUS_NXH_TSS2, + CAR.LEXUS_NX, CAR.LEXUS_RXH_TSS2} # Some ECUs that use KWP2000 have their FW versions on non-standard data identifiers. # Toyota diagnostic software first gets the supported data ids, then queries them one by one.