mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 00:03:45 +08:00
fw_versions: type annotate test_brand_ecu_matches (#31272)
* test this * we old-commit-hash: 341f8420dbd309c8465e1872839baacd1c1f3438
This commit is contained in:
@@ -201,12 +201,12 @@ def get_present_ecus(logcan, sendcan, num_pandas=1) -> Set[EcuAddrBusType]:
|
||||
return ecu_responses
|
||||
|
||||
|
||||
def get_brand_ecu_matches(ecu_rx_addrs):
|
||||
def get_brand_ecu_matches(ecu_rx_addrs: Set[EcuAddrBusType]) -> dict[str, set[AddrType]]:
|
||||
"""Returns dictionary of brands and matches with ECUs in their FW versions"""
|
||||
|
||||
brand_addrs = {brand: config.get_all_ecus(VERSIONS[brand], include_ecu_type=False) for
|
||||
brand, config in FW_QUERY_CONFIGS.items()}
|
||||
brand_matches = {brand: set() for brand, _, _ in REQUESTS}
|
||||
brand_matches: dict[str, set[AddrType]] = {brand: set() for brand, _, _ in REQUESTS}
|
||||
|
||||
brand_rx_offsets = {(brand, r.rx_offset) for brand, _, r in REQUESTS}
|
||||
for addr, sub_addr, _ in ecu_rx_addrs:
|
||||
|
||||
@@ -11,7 +11,7 @@ from cereal import car
|
||||
from openpilot.selfdrive.car.car_helpers import interfaces
|
||||
from openpilot.selfdrive.car.fingerprints import FW_VERSIONS
|
||||
from openpilot.selfdrive.car.fw_versions import FW_QUERY_CONFIGS, FUZZY_EXCLUDE_ECUS, VERSIONS, build_fw_dict, \
|
||||
match_fw_to_car, get_fw_versions, get_present_ecus
|
||||
match_fw_to_car, get_brand_ecu_matches, get_fw_versions, get_present_ecus
|
||||
from openpilot.selfdrive.car.vin import get_vin
|
||||
|
||||
CarFw = car.CarParams.CarFw
|
||||
@@ -178,6 +178,14 @@ class TestFwFingerprint(unittest.TestCase):
|
||||
self.assertFalse(request_obj.auxiliary and request_obj.bus == 1 and request_obj.obd_multiplexing,
|
||||
f"{brand.title()}: OBD multiplexed request is marked auxiliary: {request_obj}")
|
||||
|
||||
def test_brand_ecu_matches(self):
|
||||
empty_response = {brand: set() for brand in FW_QUERY_CONFIGS}
|
||||
self.assertEqual(get_brand_ecu_matches(set()), empty_response)
|
||||
|
||||
# we ignore bus
|
||||
expected_response = empty_response | {'toyota': {(0x750, 0xf)}}
|
||||
self.assertEqual(get_brand_ecu_matches({(0x758, 0xf, 99)}), expected_response)
|
||||
|
||||
|
||||
class TestFwFingerprintTiming(unittest.TestCase):
|
||||
N: int = 5
|
||||
|
||||
Reference in New Issue
Block a user