From 167b26ecf87a3505e67af8e9aa50b6a80467509e Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 31 Jul 2024 03:35:24 -0700 Subject: [PATCH 1/3] add the test fix --- selfdrive/car/tests/test_fw_fingerprint.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/selfdrive/car/tests/test_fw_fingerprint.py b/selfdrive/car/tests/test_fw_fingerprint.py index f8729725422507..f6f6ed86d7bde9 100644 --- a/selfdrive/car/tests/test_fw_fingerprint.py +++ b/selfdrive/car/tests/test_fw_fingerprint.py @@ -5,11 +5,13 @@ from parameterized import parameterized from cereal import car +from openpilot.selfdrive.car import make_can_msg from openpilot.selfdrive.car.car_helpers import interfaces from openpilot.selfdrive.car.fingerprints import FW_VERSIONS from openpilot.selfdrive.car.fw_versions import ESSENTIAL_ECUS, FW_QUERY_CONFIGS, FUZZY_EXCLUDE_ECUS, VERSIONS, build_fw_dict, \ match_fw_to_car, get_brand_ecu_matches, get_fw_versions, get_present_ecus from openpilot.selfdrive.car.vin import get_vin +from openpilot.selfdrive.pandad import can_list_to_can_capnp CarFw = car.CarParams.CarFw Ecu = car.CarParams.Ecu @@ -19,7 +21,8 @@ class FakeSocket: def receive(self, non_blocking=False): - pass + return (can_list_to_can_capnp([make_can_msg(random.randint(0x600, 0x800), b'\x00' * 8, 0)]) + if random.uniform(0, 1) > 0.5 else None) def send(self, msg): pass @@ -313,3 +316,18 @@ def test_fw_query_timing(self, subtests, mocker): total_time = round(total_times[num_pandas], 2) self._assert_timing(total_time, total_ref_time[num_pandas]) print(f'all brands, total FW query time={total_time} seconds') + + def test_get_fw_versions(self, subtests, mocker): + # some coverage on IsoTpParallelQuery and panda UDS library + # TODO: replace this with full fingerprint simulation testing + # https://github.com/commaai/panda/pull/1329 + + def fake_cloudlog_exception(*args, **kwargs): + raise + + mocker.patch("openpilot.selfdrive.car.fw_versions.set_obd_multiplexing", lambda *args: None) + mocker.patch("openpilot.common.swaglog.cloudlog.exception", fake_cloudlog_exception) + fake_socket = FakeSocket() + for brand in FW_QUERY_CONFIGS.keys(): + with subtests.test(brand=brand): + get_fw_versions(fake_socket, fake_socket, brand, num_pandas=1) From 8e2cf3281a4b3f32c26954eca29402e7174c19cc Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 31 Jul 2024 14:31:42 -0700 Subject: [PATCH 2/3] bump --- panda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda b/panda index 8c3bb0151e8907..daa739efb76e29 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit 8c3bb0151e8907ade344ccb293d58cd543e28baa +Subproject commit daa739efb76e2908bf1b2ee064be9034a8e299c3 From de262ac4bd55f75456710b61f1ee726d7e983290 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 31 Jul 2024 14:36:26 -0700 Subject: [PATCH 3/3] not sure why mypy didn't catch this --- selfdrive/car/interfaces.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py index e491de3ed6106d..6c6e544f759a55 100644 --- a/selfdrive/car/interfaces.py +++ b/selfdrive/car/interfaces.py @@ -52,6 +52,7 @@ class LatControlInputs(NamedTuple): aego: float +SendCan = tuple[int, bytes, int] TorqueFromLateralAccelCallbackType = Callable[[LatControlInputs, car.CarParams.LateralTorqueTuning, float, float, bool, bool], float] @@ -109,7 +110,7 @@ def __init__(self, CP, CarController, CarState): dbc_name = "" if self.cp is None else self.cp.dbc_name self.CC: CarControllerBase = CarController(dbc_name, CP, self.VM) - def apply(self, c: car.CarControl, now_nanos: int) -> tuple[car.CarControl.Actuators, list[tuple[int, int, bytes, int]]]: + def apply(self, c: car.CarControl, now_nanos: int) -> tuple[car.CarControl.Actuators, list[SendCan]]: return self.CC.update(c, self.CS, now_nanos) @staticmethod @@ -462,9 +463,6 @@ def get_loopback_can_parser(CP): return None -SendCan = tuple[int, int, bytes, int] - - class CarControllerBase(ABC): def __init__(self, dbc_name: str, CP, VM): self.CP = CP