use less ECUs

pull/28641/head
Shane Smiskol 2 years ago
parent 024f15dcc4
commit c34024ad3d
  1. 13
      selfdrive/car/toyota/tests/test_toyota.py
  2. 32
      selfdrive/car/toyota/values.py

@ -1,4 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import random
from hypothesis import given, settings, strategies as st from hypothesis import given, settings, strategies as st
import unittest import unittest
@ -131,8 +132,18 @@ class TestToyotaFingerprint(unittest.TestCase):
CAR.LEXUS_ES_TSS2, CAR.LEXUS_ES_TSS2,
CAR.LEXUS_RX_TSS2, CAR.LEXUS_RX_TSS2,
CAR.CHR, CAR.CHR,
CAR.CHRH,
CAR.COROLLA_TSS2, 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,
} }
# excluded_platforms = {_car for _car in FW_VERSIONS}
platforms_with_shared_codes = set() platforms_with_shared_codes = set()
for platform, fw_by_addr in FW_VERSIONS.items(): for platform, fw_by_addr in FW_VERSIONS.items():
@ -148,8 +159,10 @@ class TestToyotaFingerprint(unittest.TestCase):
if len(matches) == 1: if len(matches) == 1:
self.assertEqual(list(matches)[0], platform) self.assertEqual(list(matches)[0], platform)
else: else:
print('matches', platform, matches)
platforms_with_shared_codes.add(platform) 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))) self.assertEqual(platforms_with_shared_codes, excluded_platforms, (len(platforms_with_shared_codes), len(FW_VERSIONS)))

@ -301,17 +301,27 @@ def match_fw_to_car_fuzzy(live_fw_versions) -> Set[str]:
# Check part number + platform code + major version matches for any found versions # Check part number + platform code + major version matches for any found versions
# Then check that sub-version for the above is within range (splits model years) # Then check that sub-version for the above is within range (splits model years)
for found_platform_code, found_sub_versions in found_platform_codes.items():
if found_platform_code in expected_platform_codes:
expected_sub_versions = expected_platform_codes[found_platform_code]
# Check any sub-version within range in the database for this part-platform-version combo # Sub-versions are incremented for minor recalls, do not need to be checked.
if any(min(expected_sub_versions) <= found_sub_version <= max(expected_sub_versions) for # Platform codes and major versions change for different physical parts. For example,
found_sub_version in found_sub_versions): # engine's major version describes actual Toyota engine type.
valid_found_ecus.add(addr)
break if not any(found_platform_code in expected_platform_codes for found_platform_code in found_platform_codes):
break
valid_found_ecus.add(addr)
# for found_platform_code, found_sub_versions in found_platform_codes.items():
# if found_platform_code in expected_platform_codes:
# expected_sub_versions = expected_platform_codes[found_platform_code]
#
# # Check any sub-version within range in the database for this part-platform-version combo
# if any(min(expected_sub_versions) <= found_sub_version <= max(expected_sub_versions) for
# found_sub_version in found_sub_versions):
# valid_found_ecus.add(addr)
# break
# If all live ECUs pass all checks for candidate, add it as a match # If all live ECUs pass all checks for candidate, add it as a match
# print(candidate, valid_expected_ecus, valid_found_ecus)
if valid_expected_ecus.issubset(valid_found_ecus): if valid_expected_ecus.issubset(valid_found_ecus):
candidates.add(candidate) candidates.add(candidate)
@ -333,9 +343,9 @@ LONG_FW_PATTERN = re.compile(b'(?P<part>[A-Z0-9]{5})(?P<platform>[A-Z0-9]{2})(?P
FW_LEN_CODE = re.compile(b'^[\x01-\x03]') # highest seen is 3 chunks, 16 bytes each FW_LEN_CODE = re.compile(b'^[\x01-\x03]') # highest seen is 3 chunks, 16 bytes each
FW_CHUNK_LEN = 16 FW_CHUNK_LEN = 16
# List of ECUs expected to have platform codes # List of ECUs that are most unique across openpilot platforms
# Engine is not well understood at this time (lots of variability in major version) # TODO: use hybrid ECU, splits similar ICE and hybrid variants
PLATFORM_CODE_ECUS = [Ecu.abs, Ecu.eps, Ecu.dsu, Ecu.fwdCamera, Ecu.fwdRadar] PLATFORM_CODE_ECUS = [Ecu.abs, Ecu.eps, Ecu.fwdCamera]
# Some ECUs that use KWP2000 have their FW versions on non-standard data identifiers. # Some ECUs that use KWP2000 have their FW versions on non-standard data identifiers.

Loading…
Cancel
Save