|
|
@ -144,8 +144,8 @@ def match_fw_to_car_exact(live_fw_versions: LiveFwVersions, match_brand: str = N |
|
|
|
return set(candidates.keys()) - invalid |
|
|
|
return set(candidates.keys()) - invalid |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def match_fw_to_car(fw_versions: list[capnp.lib.capnp._DynamicStructBuilder], allow_exact: bool = True, allow_fuzzy: bool = True, |
|
|
|
def match_fw_to_car(fw_versions: list[capnp.lib.capnp._DynamicStructBuilder], vin: str, allow_exact: bool = True, |
|
|
|
log: bool = True) -> tuple[bool, set[str]]: |
|
|
|
allow_fuzzy: bool = True, log: bool = True) -> tuple[bool, set[str]]: |
|
|
|
# Try exact matching first |
|
|
|
# Try exact matching first |
|
|
|
exact_matches: list[tuple[bool, MatchFwToCar]] = [] |
|
|
|
exact_matches: list[tuple[bool, MatchFwToCar]] = [] |
|
|
|
if allow_exact: |
|
|
|
if allow_exact: |
|
|
@ -158,12 +158,18 @@ def match_fw_to_car(fw_versions: list[capnp.lib.capnp._DynamicStructBuilder], al |
|
|
|
matches: set[str] = set() |
|
|
|
matches: set[str] = set() |
|
|
|
for brand in VERSIONS.keys(): |
|
|
|
for brand in VERSIONS.keys(): |
|
|
|
fw_versions_dict = build_fw_dict(fw_versions, filter_brand=brand) |
|
|
|
fw_versions_dict = build_fw_dict(fw_versions, filter_brand=brand) |
|
|
|
matches |= match_func(fw_versions_dict, match_brand=brand, log=log) |
|
|
|
cur_matches = match_func(fw_versions_dict, match_brand=brand, log=log) |
|
|
|
|
|
|
|
|
|
|
|
# If specified and no matches so far, fall back to brand's fuzzy fingerprinting function |
|
|
|
# If specified and no matches so far, fall back to brand's fuzzy fingerprinting function |
|
|
|
config = FW_QUERY_CONFIGS[brand] |
|
|
|
config = FW_QUERY_CONFIGS[brand] |
|
|
|
if not exact_match and not len(matches) and config.match_fw_to_car_fuzzy is not None: |
|
|
|
if not exact_match and not len(cur_matches) and config.match_fw_to_car_fuzzy is not None: |
|
|
|
matches |= config.match_fw_to_car_fuzzy(fw_versions_dict, VERSIONS[brand]) |
|
|
|
cur_matches |= config.match_fw_to_car_fuzzy(fw_versions_dict, VERSIONS[brand]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# FIXME: this is super ugly |
|
|
|
|
|
|
|
if len(cur_matches) != 1 and config.match_fw_to_car_custom is not None: |
|
|
|
|
|
|
|
cur_matches = config.match_fw_to_car_custom(fw_versions_dict, vin, VERSIONS[brand]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
matches |= cur_matches |
|
|
|
|
|
|
|
|
|
|
|
if len(matches): |
|
|
|
if len(matches): |
|
|
|
return exact_match, matches |
|
|
|
return exact_match, matches |
|
|
@ -237,7 +243,7 @@ def set_obd_multiplexing(params: Params, obd_multiplexing: bool): |
|
|
|
cloudlog.warning("OBD multiplexing set successfully") |
|
|
|
cloudlog.warning("OBD multiplexing set successfully") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_fw_versions_ordered(logcan, sendcan, ecu_rx_addrs: set[EcuAddrBusType], timeout: float = 0.1, num_pandas: int = 1, |
|
|
|
def get_fw_versions_ordered(logcan, sendcan, vin: str, ecu_rx_addrs: set[EcuAddrBusType], timeout: float = 0.1, num_pandas: int = 1, |
|
|
|
debug: bool = False, progress: bool = False) -> list[capnp.lib.capnp._DynamicStructBuilder]: |
|
|
|
debug: bool = False, progress: bool = False) -> list[capnp.lib.capnp._DynamicStructBuilder]: |
|
|
|
"""Queries for FW versions ordering brands by likelihood, breaks when exact match is found""" |
|
|
|
"""Queries for FW versions ordering brands by likelihood, breaks when exact match is found""" |
|
|
|
|
|
|
|
|
|
|
@ -253,7 +259,7 @@ def get_fw_versions_ordered(logcan, sendcan, ecu_rx_addrs: set[EcuAddrBusType], |
|
|
|
all_car_fw.extend(car_fw) |
|
|
|
all_car_fw.extend(car_fw) |
|
|
|
|
|
|
|
|
|
|
|
# If there is a match using this brand's FW alone, finish querying early |
|
|
|
# If there is a match using this brand's FW alone, finish querying early |
|
|
|
_, matches = match_fw_to_car(car_fw, log=False) |
|
|
|
_, matches = match_fw_to_car(car_fw, vin, log=False) |
|
|
|
if len(matches) == 1: |
|
|
|
if len(matches) == 1: |
|
|
|
break |
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|