revert back to what we did before

pull/26939/head
Shane Smiskol 2 years ago
parent 589ba6b7eb
commit cbe1d55c42
  1. 30
      selfdrive/car/fw_versions.py
  2. 2
      selfdrive/car/hyundai/tests/test_hyundai.py

@ -81,28 +81,19 @@ def match_fw_to_car_fuzzy(fw_versions_dict, config, log=True, exclude=None):
for platform_code in config.fuzzy_get_platform_codes(fws): for platform_code in config.fuzzy_get_platform_codes(fws):
all_platform_codes[(addr[1], addr[2], platform_code)].append(candidate) all_platform_codes[(addr[1], addr[2], platform_code)].append(candidate)
# TODO: we really want to support both ways of fuzzy FP, but we don't want to partially match with both.
# meaning we get one radar platform code match, no camera platform code match, and a random exact FW ECU match.
# when matching with platform codes, it should be all ECUs specified in the config
# and if we don't match all ECUs with platform codes, we should fall back on normal full FW fuzzy matching, not mixing both
# UPDATE: i'm reframing this such that fuzzy FP adds matches, not replaces any logic or matches or minimum count.
# makes it easier to understand/less complex and doesn't try to fix general issues with fuzzy FP by masking over it
# by splitting up fuzzy FP into exact matching vs. platform code matching. that should be handled explicitly.
# there may be issues with this approach, but they weren't already there, and this PR is trying to do a lot already
def fuzzy_match(use_config):
matched_ecus = set() matched_ecus = set()
candidate = None candidate = None
for addr, versions in fw_versions_dict.items(): for addr, versions in fw_versions_dict.items():
ecu_key = (addr[0], addr[1]) ecu_key = (addr[0], addr[1])
for version in versions: for version in versions:
candidates = set() # All cars that have this FW response on the specified address
if use_config: candidates = all_fw_versions[(*ecu_key, version)]
# If not one candidate for this ECU and version, try platform codes + dates
if len(candidates) != 1 and config.fuzzy_get_platform_codes is not None:
# Returns one or none, all cars that have this platform code # Returns one or none, all cars that have this platform code
for platform_code in config.fuzzy_get_platform_codes([version]): for platform_code in config.fuzzy_get_platform_codes([version]):
candidates = all_platform_codes[(*ecu_key, platform_code)] candidates = all_platform_codes[(*ecu_key, platform_code)]
else:
# All cars that have this FW response on the specified address
candidates = all_fw_versions[(*ecu_key, version)]
if len(candidates) == 1: if len(candidates) == 1:
matched_ecus.add(ecu_key) matched_ecus.add(ecu_key)
@ -110,16 +101,7 @@ def match_fw_to_car_fuzzy(fw_versions_dict, config, log=True, exclude=None):
candidate = candidates[0] candidate = candidates[0]
# We uniquely matched two different cars. No fuzzy match possible # We uniquely matched two different cars. No fuzzy match possible
elif candidate != candidates[0]: elif candidate != candidates[0]:
return None, matched_ecus return set()
return candidate, matched_ecus
# Try to fuzzy fingerprint both with and without platform codes independently
for use_config in {config.fuzzy_get_platform_codes is not None}:
candidate, matched_ecus = fuzzy_match(use_config)
if candidate is None:
continue
# Note that it is possible to match to a candidate without all its ECUs being present # Note that it is possible to match to a candidate without all its ECUs being present
# if there are enough matches. FIXME: parameterize this or require all ECUs to exist like exact matching # if there are enough matches. FIXME: parameterize this or require all ECUs to exist like exact matching

@ -86,7 +86,7 @@ class TestHyundaiFingerprint(TestFwFingerprintBase):
b'ON-1904', b'ON-1905', b'ON-1906', b'ON-1907'}) b'ON-1904', b'ON-1905', b'ON-1906', b'ON-1907'})
def test_excluded_platforms_new(self): def test_excluded_platforms_new(self):
# Asserts a list of platforms that will not fuzzy fingerprint due to shared platform codes # 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 and detect features # This list can be shrunk as we combine platforms and detect features
excluded_platforms = { excluded_platforms = {
CAR.GENESIS_G70, CAR.GENESIS_G70,

Loading…
Cancel
Save