mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-03-02 09:43:54 +08:00
make_can_msg: returns tuple (#33222)
* bump
* make_man_msg returns tuple
* fix CI.update typing
* bump
* better name
* Revert "better name"
This reverts commit 4deb38d4ed99e43721960f69da1dd46a1069eb42.
* common
old-commit-hash: 51bd368214
This commit is contained in:
Submodule opendbc_repo updated: 1e9f853615...f4d077b832
@@ -12,6 +12,8 @@ from panda.python.uds import SERVICE_TYPE
|
||||
from openpilot.selfdrive.car.docs_definitions import CarDocs
|
||||
from openpilot.selfdrive.car.helpers import clip, interp
|
||||
|
||||
CanMsgType = tuple[int, bytes, int]
|
||||
|
||||
# set up logging
|
||||
carlog = logging.getLogger('carlog')
|
||||
carlog.setLevel(logging.INFO)
|
||||
@@ -193,8 +195,8 @@ def get_friction(lateral_accel_error: float, lateral_accel_deadzone: float, fric
|
||||
return friction
|
||||
|
||||
|
||||
def make_can_msg(addr, dat, bus):
|
||||
return [addr, dat, bus]
|
||||
def make_can_msg(addr: int, dat: bytes, bus: int) -> CanMsgType:
|
||||
return addr, dat, bus
|
||||
|
||||
|
||||
def make_tester_present_msg(addr, bus, subaddr=None, suppress_response=False):
|
||||
|
||||
@@ -11,7 +11,8 @@ from functools import cache
|
||||
from cereal import car
|
||||
from openpilot.common.basedir import BASEDIR
|
||||
from openpilot.common.simple_kalman import KF1D, get_kalman_gain
|
||||
from openpilot.selfdrive.car import DT_CTRL, apply_hysteresis, gen_empty_fingerprint, scale_rot_inertia, scale_tire_stiffness, get_friction, STD_CARGO_KG
|
||||
from openpilot.selfdrive.car import CanMsgType, DT_CTRL, apply_hysteresis, gen_empty_fingerprint, scale_rot_inertia, scale_tire_stiffness, get_friction, \
|
||||
STD_CARGO_KG
|
||||
from openpilot.selfdrive.car.conversions import Conversions as CV
|
||||
from openpilot.selfdrive.car.helpers import clip
|
||||
from openpilot.selfdrive.car.values import PLATFORMS
|
||||
@@ -51,7 +52,6 @@ class LatControlInputs(NamedTuple):
|
||||
aego: float
|
||||
|
||||
|
||||
SendCan = tuple[int, bytes, int]
|
||||
TorqueFromLateralAccelCallbackType = Callable[[LatControlInputs, car.CarParams.LateralTorqueTuning, float, float, bool, bool], float]
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ class CarInterfaceBase(ABC):
|
||||
dbc_name = "" if self.cp is None else self.cp.dbc_name
|
||||
self.CC: CarControllerBase = CarController(dbc_name, CP)
|
||||
|
||||
def apply(self, c: car.CarControl, now_nanos: int) -> tuple[car.CarControl.Actuators, list[SendCan]]:
|
||||
def apply(self, c: car.CarControl, now_nanos: int) -> tuple[car.CarControl.Actuators, list[CanMsgType]]:
|
||||
return self.CC.update(c, self.CS, now_nanos)
|
||||
|
||||
@staticmethod
|
||||
@@ -228,7 +228,7 @@ class CarInterfaceBase(ABC):
|
||||
def _update(self, c: car.CarControl) -> car.CarState:
|
||||
pass
|
||||
|
||||
def update(self, c: car.CarControl, can_packets: list[int, list[int, bytes, int]]) -> car.CarState:
|
||||
def update(self, c: car.CarControl, can_packets: list[tuple[int, list[CanMsgType]]]) -> car.CarState:
|
||||
# parse can
|
||||
for cp in self.can_parsers:
|
||||
if cp is not None:
|
||||
@@ -467,7 +467,7 @@ class CarControllerBase(ABC):
|
||||
self.frame = 0
|
||||
|
||||
@abstractmethod
|
||||
def update(self, CC: car.CarControl.Actuators, CS: car.CarState, now_nanos: int) -> tuple[car.CarControl.Actuators, list[SendCan]]:
|
||||
def update(self, CC: car.CarControl.Actuators, CS: car.CarState, now_nanos: int) -> tuple[car.CarControl.Actuators, list[CanMsgType]]:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from collections import defaultdict
|
||||
from functools import partial
|
||||
|
||||
import cereal.messaging as messaging
|
||||
from openpilot.selfdrive.car import carlog
|
||||
from openpilot.selfdrive.car import carlog, CanMsgType
|
||||
from openpilot.selfdrive.car.fw_query_definitions import AddrType
|
||||
from openpilot.selfdrive.pandad import can_list_to_can_capnp
|
||||
from panda.python.uds import CanClient, IsoTpMessage, FUNCTIONAL_ADDRS, get_rx_addr_for_tx_addr
|
||||
@@ -27,7 +27,7 @@ class IsoTpParallelQuery:
|
||||
assert tx_addr not in FUNCTIONAL_ADDRS, f"Functional address should be defined in functional_addrs: {hex(tx_addr)}"
|
||||
|
||||
self.msg_addrs = {tx_addr: get_rx_addr_for_tx_addr(tx_addr[0], rx_offset=response_offset) for tx_addr in real_addrs}
|
||||
self.msg_buffer: dict[int, list[tuple[int, bytes, int]]] = defaultdict(list)
|
||||
self.msg_buffer: dict[int, list[CanMsgType]] = defaultdict(list)
|
||||
|
||||
def rx(self):
|
||||
"""Drain can socket and sort messages into buffers based on address"""
|
||||
|
||||
@@ -50,7 +50,7 @@ def can_capnp_to_list(strings, msgtype='can'):
|
||||
cdef vector[CanData].iterator it = data.begin()
|
||||
while it != data.end():
|
||||
d = &deref(it)
|
||||
frames = [[f.address, (<char *>&f.dat[0])[:f.dat.size()], f.src] for f in d.frames]
|
||||
result.append([d.nanos, frames])
|
||||
frames = [(f.address, (<char *>&f.dat[0])[:f.dat.size()], f.src) for f in d.frames]
|
||||
result.append((d.nanos, frames))
|
||||
preinc(it)
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user