diff --git a/selfdrive/car/fw_query_definitions.py b/selfdrive/car/fw_query_definitions.py index 11a4d10c2c..114de6cc5d 100755 --- a/selfdrive/car/fw_query_definitions.py +++ b/selfdrive/car/fw_query_definitions.py @@ -81,6 +81,7 @@ class FwQueryConfig: # A function to get uniquely identifiable codes for a version # TODO: take list of versions and return set of platform codes fuzzy_get_platform_codes: Optional[Callable] = None + fuzzy_ecus: List[capnp.lib.capnp._EnumModule] = field(default_factory=set) # TODO: below func is to be replaced by above two # A function that each make can provide to fuzzy fingerprint reliably on that make diff --git a/selfdrive/car/fw_versions.py b/selfdrive/car/fw_versions.py index 80908cc6ca..c15ee5187c 100755 --- a/selfdrive/car/fw_versions.py +++ b/selfdrive/car/fw_versions.py @@ -59,7 +59,7 @@ def match_fw_to_car_fuzzy(fw_versions_dict, config, log=True, exclude=None): # Getting this exactly right isn't crucial, but excluding camera and radar makes it almost # impossible to get 3 matching versions, even if two models with shared parts are released at the same # time and only one is in our database. - # exclude_types = [Ecu.fwdCamera, Ecu.fwdRadar, Ecu.eps, Ecu.debug] + exclude_types = [Ecu.fwdCamera, Ecu.fwdRadar, Ecu.eps, Ecu.debug] # Build lookup table from (addr, sub_addr, fw) to list of candidate cars all_fw_versions = defaultdict(set) @@ -77,16 +77,18 @@ def match_fw_to_car_fuzzy(fw_versions_dict, config, log=True, exclude=None): if addr[0] not in [Ecu.fwdCamera, Ecu.fwdRadar]: continue for f in fws: - all_fw_versions[(addr[1], addr[2], f)].add(candidate) + if addr[0] not in exclude_types: + all_fw_versions[(addr[1], addr[2], f)].add(candidate) # Add platform codes to lookup dict if config specifies a function if config.fuzzy_get_platform_codes is not None: - platform_codes = config.fuzzy_get_platform_codes([f]) - assert len(platform_codes) < 2 # TODO: remove and test? - if len(platform_codes) == 1: - print(platform_codes, f) - platform_code = list(platform_codes)[0] - all_platform_codes[(addr[1], addr[2], platform_code)].add(candidate) + if addr[0] in config.fuzzy_ecus: + platform_codes = config.fuzzy_get_platform_codes([f]) + assert len(platform_codes) < 2 # TODO: remove and test? + if len(platform_codes) == 1: + print(platform_codes, f) + platform_code = list(platform_codes)[0] + all_platform_codes[(addr[1], addr[2], platform_code)].add(candidate) print(all_platform_codes) match_count = 0 diff --git a/selfdrive/car/hyundai/values.py b/selfdrive/car/hyundai/values.py index bfbbacba68..bda0e2baf0 100644 --- a/selfdrive/car/hyundai/values.py +++ b/selfdrive/car/hyundai/values.py @@ -451,6 +451,7 @@ FW_QUERY_CONFIG = FwQueryConfig( # Just one platform code match from radar or camera is enough fuzzy_min_match_count=1, fuzzy_get_platform_codes=get_platform_codes, + fuzzy_ecus=[Ecu.fwdRadar, Ecu.fwdCamera], # TODO: old, remove match_fw_to_car_fuzzy=match_fw_to_hyundai_fuzzy,