mirror of https://github.com/commaai/openpilot.git
cleanup fingerprinting typing (#30801)
* wip
* undo + add can fingerprints
* add can fingerpints
* those should go there
old-commit-hash: adca970ca9
This commit is contained in:
parent
f65ccca8e0
commit
1314156365
|
@ -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
|
||||
|
|
|
@ -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)):
|
||||
|
|
Loading…
Reference in New Issue