mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-07-12 00:12:05 +08:00
Revert "FPv2: fingerprint on all FW combinations" (#25417)
* Revert "FPv2: fingerprint on all FW combinations (#25204)"
This reverts commit ee081f278b.
* Revert "Revert "FPv2: fingerprint on all FW combinations (#25204)""
This reverts commit bb68b7bc1c28ba8c67f3051b8f99fabc42e85771.
* For breaking, match only with current brand's FW
* Add comment for fuzzy matching
* fingerprint (online) only using FW from that brand
* test_fw_query_on_routes fingerprints like online
* extend match_fw_to_car to work for test_fw_query_on_routes
* Apply suggestions from code review
This commit is contained in:
@@ -337,17 +337,21 @@ def match_fw_to_car_exact(fw_versions_dict):
|
||||
return set(candidates.keys()) - set(invalid)
|
||||
|
||||
|
||||
def match_fw_to_car(fw_versions, allow_fuzzy=True):
|
||||
def match_fw_to_car(fw_versions, allow_exact=True, allow_fuzzy=True):
|
||||
# Try exact matching first
|
||||
exact_matches = [(True, match_fw_to_car_exact)]
|
||||
exact_matches = []
|
||||
if allow_exact:
|
||||
exact_matches = [(True, match_fw_to_car_exact)]
|
||||
if allow_fuzzy:
|
||||
exact_matches.append((False, match_fw_to_car_fuzzy))
|
||||
|
||||
brands = get_interface_attr('FW_VERSIONS', ignore_none=True).keys()
|
||||
for exact_match, match_func in exact_matches:
|
||||
# TODO: For each brand, attempt to fingerprint using only FW returned from its queries
|
||||
# For each brand, attempt to fingerprint using all FW returned from its queries
|
||||
matches = set()
|
||||
fw_versions_dict = build_fw_dict(fw_versions, filter_brand=None)
|
||||
matches |= match_func(fw_versions_dict)
|
||||
for brand in brands:
|
||||
fw_versions_dict = build_fw_dict(fw_versions, filter_brand=brand)
|
||||
matches |= match_func(fw_versions_dict)
|
||||
|
||||
if len(matches):
|
||||
return exact_match, matches
|
||||
@@ -416,9 +420,8 @@ def get_fw_versions_ordered(logcan, sendcan, ecu_rx_addrs, timeout=0.1, debug=Fa
|
||||
for brand in sorted(brand_matches, key=lambda b: len(brand_matches[b]), reverse=True):
|
||||
car_fw = get_fw_versions(logcan, sendcan, query_brand=brand, timeout=timeout, debug=debug, progress=progress)
|
||||
all_car_fw.extend(car_fw)
|
||||
|
||||
# TODO: Until erroneous FW versions are removed, try to fingerprint on all possible combinations so far
|
||||
_, matches = match_fw_to_car(all_car_fw, allow_fuzzy=False)
|
||||
# Try to match using FW returned from this brand only
|
||||
matches = match_fw_to_car_exact(build_fw_dict(car_fw))
|
||||
if len(matches) == 1:
|
||||
break
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ from tools.lib.logreader import LogReader
|
||||
from tools.lib.route import Route
|
||||
from selfdrive.car.interfaces import get_interface_attr
|
||||
from selfdrive.car.car_helpers import interface_names
|
||||
from selfdrive.car.fw_versions import match_fw_to_car_exact, match_fw_to_car_fuzzy, build_fw_dict
|
||||
from selfdrive.car.fw_versions import match_fw_to_car
|
||||
|
||||
|
||||
NO_API = "NO_API" in os.environ
|
||||
@@ -89,9 +89,8 @@ if __name__ == "__main__":
|
||||
print("not in supported cars")
|
||||
break
|
||||
|
||||
fw_versions_dict = build_fw_dict(car_fw)
|
||||
exact_matches = match_fw_to_car_exact(fw_versions_dict)
|
||||
fuzzy_matches = match_fw_to_car_fuzzy(fw_versions_dict)
|
||||
_, exact_matches = match_fw_to_car(car_fw, allow_exact=True, allow_fuzzy=False)
|
||||
_, fuzzy_matches = match_fw_to_car(car_fw, allow_exact=False, allow_fuzzy=True)
|
||||
|
||||
if (len(exact_matches) == 1) and (list(exact_matches)[0] == live_fingerprint):
|
||||
good_exact += 1
|
||||
|
||||
Reference in New Issue
Block a user