From ba7a60c5a20c5f252bc89ba3e2559edf5ab65c59 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 7 Aug 2024 02:05:32 -0500 Subject: [PATCH] remove CAN capnp conversion from car interfaces (#33218) remove pandad from interfaces --- .importlinter | 1 - selfdrive/car/card.py | 4 ++-- selfdrive/car/interfaces.py | 6 ++---- selfdrive/car/tests/test_models.py | 8 ++++---- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.importlinter b/.importlinter index f2d1d4f2b03a7c..e510ee91fbd034 100644 --- a/.importlinter +++ b/.importlinter @@ -38,7 +38,6 @@ ignore_imports = openpilot.selfdrive.car.ecu_addrs -> openpilot.common.params # requires generic CAN send/receive functions openpilot.selfdrive.car.ecu_addrs -> openpilot.selfdrive.pandad - openpilot.selfdrive.car.interfaces -> openpilot.selfdrive.pandad openpilot.selfdrive.car.isotp_parallel_query -> openpilot.selfdrive.pandad openpilot.selfdrive.car.tests.test_fw_fingerprint -> openpilot.selfdrive.pandad diff --git a/selfdrive/car/card.py b/selfdrive/car/card.py index e878a14c31660c..a8afa0dec98de8 100755 --- a/selfdrive/car/card.py +++ b/selfdrive/car/card.py @@ -12,7 +12,7 @@ from openpilot.common.realtime import config_realtime_process, Priority, Ratekeeper from openpilot.common.swaglog import cloudlog, ForwardingHandler -from openpilot.selfdrive.pandad import can_list_to_can_capnp +from openpilot.selfdrive.pandad import can_capnp_to_list, can_list_to_can_capnp from openpilot.selfdrive.car import DT_CTRL, carlog from openpilot.selfdrive.car.car_helpers import get_car, get_one_can from openpilot.selfdrive.car.interfaces import CarInterfaceBase @@ -108,7 +108,7 @@ def state_update(self) -> car.CarState: # Update carState from CAN can_strs = messaging.drain_sock_raw(self.can_sock, wait_for_one=True) - CS = self.CI.update(self.CC_prev, can_strs) + CS = self.CI.update(self.CC_prev, can_capnp_to_list(can_strs)) self.sm.update(0) diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py index 90d50f090383a5..68f7f1ec2456d8 100644 --- a/selfdrive/car/interfaces.py +++ b/selfdrive/car/interfaces.py @@ -16,7 +16,6 @@ from openpilot.selfdrive.car.helpers import clip from openpilot.selfdrive.car.values import PLATFORMS from openpilot.selfdrive.controls.lib.events import Events -from openpilot.selfdrive.pandad import can_capnp_to_list ButtonType = car.CarState.ButtonEvent.Type GearShifter = car.CarState.GearShifter @@ -229,12 +228,11 @@ def configure_torque_tune(candidate, tune, steering_angle_deadzone_deg=0.0, use_ def _update(self, c: car.CarControl) -> car.CarState: pass - def update(self, c: car.CarControl, can_strings: list[bytes]) -> car.CarState: + def update(self, c: car.CarControl, can_packets: list[int, list[int, bytes, int]]) -> car.CarState: # parse can - can_list = can_capnp_to_list(can_strings) for cp in self.can_parsers: if cp is not None: - cp.update_strings(can_list) + cp.update_strings(can_packets) # get CarState ret = self._update(c) diff --git a/selfdrive/car/tests/test_models.py b/selfdrive/car/tests/test_models.py index 22a80f359a93af..f57def03628bd2 100644 --- a/selfdrive/car/tests/test_models.py +++ b/selfdrive/car/tests/test_models.py @@ -217,7 +217,7 @@ def test_car_interface(self): CC = car.CarControl.new_message().as_reader() for i, msg in enumerate(self.can_msgs): - CS = self.CI.update(CC, (msg.as_builder().to_bytes(),)) + CS = self.CI.update(CC, can_capnp_to_list((msg.as_builder().to_bytes(),))) self.CI.apply(CC, msg.logMonoTime) if CS.canValid: @@ -358,7 +358,7 @@ def test_panda_safety_carstate_fuzzy(self, data): can = messaging.new_message('can', 1) can.can = [log.CanData(address=address, dat=dat, src=bus)] - CS = self.CI.update(CC, (can.to_bytes(),)) + CS = self.CI.update(CC, can_capnp_to_list((can.to_bytes(),))) if self.safety.get_gas_pressed_prev() != prev_panda_gas: self.assertEqual(CS.gasPressed, self.safety.get_gas_pressed_prev()) @@ -397,7 +397,7 @@ def test_panda_safety_carstate(self): # warm up pass, as initial states may be different for can in self.can_msgs[:300]: - self.CI.update(CC, (can.as_builder().to_bytes(), )) + self.CI.update(CC, can_capnp_to_list((can.as_builder().to_bytes(), ))) for msg in filter(lambda m: m.src in range(64), can.can): to_send = libpanda_py.make_CANPacket(msg.address, msg.src % 4, msg.dat) self.safety.safety_rx_hook(to_send) @@ -407,7 +407,7 @@ def test_panda_safety_carstate(self): checks = defaultdict(int) card = Car(CI=self.CI) for idx, can in enumerate(self.can_msgs): - CS = self.CI.update(CC, (can.as_builder().to_bytes(), )) + CS = self.CI.update(CC, can_capnp_to_list((can.as_builder().to_bytes(), ))) for msg in filter(lambda m: m.src in range(64), can.can): to_send = libpanda_py.make_CANPacket(msg.address, msg.src % 4, msg.dat) ret = self.safety.safety_rx_hook(to_send)