diff --git a/selfdrive/car/fingerprints.py b/selfdrive/car/fingerprints.py index 1d627e4b37..7ff700f4c5 100644 --- a/selfdrive/car/fingerprints.py +++ b/selfdrive/car/fingerprints.py @@ -1,5 +1,7 @@ +from typing import Dict, List from openpilot.selfdrive.car.interfaces import get_interface_attr +OfflineCanFingerprints = Dict[str, List[Dict[int, int]]] FW_VERSIONS = get_interface_attr('FW_VERSIONS', combine_brands=True, ignore_none=True) _FINGERPRINTS = get_interface_attr('FINGERPRINTS', combine_brands=True, ignore_none=True) @@ -7,7 +9,7 @@ _FINGERPRINTS = get_interface_attr('FINGERPRINTS', combine_brands=True, ignore_n _DEBUG_ADDRESS = {1880: 8} # reserved for debug purposes -def is_valid_for_fingerprint(msg, car_fingerprint): +def is_valid_for_fingerprint(msg, car_fingerprint: OfflineCanFingerprints): adr = msg.address # ignore addresses that are more than 11 bits return (adr in car_fingerprint and car_fingerprint[adr] == len(msg.dat)) or adr >= 0x800 diff --git a/selfdrive/car/fw_query_definitions.py b/selfdrive/car/fw_query_definitions.py index 4ffb087bdc..410040b10e 100755 --- a/selfdrive/car/fw_query_definitions.py +++ b/selfdrive/car/fw_query_definitions.py @@ -11,9 +11,8 @@ AddrType = Tuple[int, Optional[int]] EcuAddrBusType = Tuple[int, Optional[int], int] EcuAddrSubAddr = Tuple[int, int, Optional[int]] -LIVE_FW_VERSIONS = Dict[AddrType, Set[bytes]] -OFFLINE_FW_VERSIONS = Dict[str, Dict[EcuAddrSubAddr, List[bytes]]] - +LiveFwVersions = Dict[AddrType, Set[bytes]] +OfflineFwVersions = Dict[str, Dict[EcuAddrSubAddr, List[bytes]]] def p16(val): return struct.pack("!H", val) @@ -83,7 +82,7 @@ class FwQueryConfig: extra_ecus: List[Tuple[capnp.lib.capnp._EnumModule, int, Optional[int]]] = field(default_factory=list) # Function a brand can implement to provide better fuzzy matching. Takes in FW versions, # returns set of candidates. Only will match if one candidate is returned - match_fw_to_car_fuzzy: Optional[Callable[[LIVE_FW_VERSIONS, OFFLINE_FW_VERSIONS], Set[str]]] = None + match_fw_to_car_fuzzy: Optional[Callable[[LiveFwVersions, OfflineFwVersions], Set[str]]] = None def __post_init__(self): for i in range(len(self.requests)):