more sendcan -> can_send references

pull/33215/head
Shane Smiskol 9 months ago
parent c17b1c6347
commit 3742625e85
  1. 7
      selfdrive/car/card.py
  2. 6
      selfdrive/car/disable_ecu.py
  3. 4
      selfdrive/car/honda/interface.py
  4. 6
      selfdrive/car/hyundai/interface.py
  5. 4
      selfdrive/car/interfaces.py
  6. 4
      selfdrive/car/subaru/interface.py
  7. 4
      selfdrive/car/toyota/interface.py

@ -88,6 +88,8 @@ class Car:
self.params = Params() self.params = Params()
self.can_callbacks = can_comm_callbacks(self.can_sock, self.pm.sock['sendcan'])
if CI is None: if CI is None:
# wait for one pandaState and one CAN packet # wait for one pandaState and one CAN packet
print("Waiting for CAN messages...") print("Waiting for CAN messages...")
@ -96,8 +98,7 @@ class Car:
experimental_long_allowed = self.params.get_bool("ExperimentalLongitudinalEnabled") experimental_long_allowed = self.params.get_bool("ExperimentalLongitudinalEnabled")
num_pandas = len(messaging.recv_one_retry(self.sm.sock['pandaStates']).pandaStates) num_pandas = len(messaging.recv_one_retry(self.sm.sock['pandaStates']).pandaStates)
cached_params = self.params.get("CarParamsCache") cached_params = self.params.get("CarParamsCache")
self.CI = get_car(*can_comm_callbacks(self.can_sock, self.pm.sock['sendcan']), obd_callback(self.params), self.CI = get_car(*self.can_callbacks, obd_callback(self.params), experimental_long_allowed, num_pandas, cached_params)
experimental_long_allowed, num_pandas, cached_params)
self.CP = self.CI.CP self.CP = self.CI.CP
# continue onto next fingerprinting step in pandad # continue onto next fingerprinting step in pandad
@ -200,7 +201,7 @@ class Car:
if not self.initialized_prev: if not self.initialized_prev:
# Initialize CarInterface, once controls are ready # Initialize CarInterface, once controls are ready
# TODO: this can make us miss at least a few cycles when doing an ECU knockout # TODO: this can make us miss at least a few cycles when doing an ECU knockout
self.CI.init(self.CP, self.can_sock, self.pm.sock['sendcan']) self.CI.init(self.CP, *self.can_callbacks)
# signal pandad to switch to car safety mode # signal pandad to switch to car safety mode
self.params.put_bool_nonblocking("ControlsReady", True) self.params.put_bool_nonblocking("ControlsReady", True)

@ -8,7 +8,7 @@ EXT_DIAG_RESPONSE = b'\x50\x03'
COM_CONT_RESPONSE = b'' COM_CONT_RESPONSE = b''
def disable_ecu(logcan, sendcan, bus=0, addr=0x7d0, sub_addr=None, com_cont_req=b'\x28\x83\x01', timeout=0.1, retry=10, debug=False): def disable_ecu(logcan, can_send, bus=0, addr=0x7d0, sub_addr=None, com_cont_req=b'\x28\x83\x01', timeout=0.1, retry=10, debug=False):
"""Silence an ECU by disabling sending and receiving messages using UDS 0x28. """Silence an ECU by disabling sending and receiving messages using UDS 0x28.
The ECU will stay silent as long as openpilot keeps sending Tester Present. The ECU will stay silent as long as openpilot keeps sending Tester Present.
@ -18,12 +18,12 @@ def disable_ecu(logcan, sendcan, bus=0, addr=0x7d0, sub_addr=None, com_cont_req=
for i in range(retry): for i in range(retry):
try: try:
query = IsoTpParallelQuery(sendcan, logcan, bus, [(addr, sub_addr)], [EXT_DIAG_REQUEST], [EXT_DIAG_RESPONSE], debug=debug) query = IsoTpParallelQuery(can_send, logcan, bus, [(addr, sub_addr)], [EXT_DIAG_REQUEST], [EXT_DIAG_RESPONSE], debug=debug)
for _, _ in query.get_data(timeout).items(): for _, _ in query.get_data(timeout).items():
carlog.warning("communication control disable tx/rx ...") carlog.warning("communication control disable tx/rx ...")
query = IsoTpParallelQuery(sendcan, logcan, bus, [(addr, sub_addr)], [com_cont_req], [COM_CONT_RESPONSE], debug=debug) query = IsoTpParallelQuery(can_send, logcan, bus, [(addr, sub_addr)], [com_cont_req], [COM_CONT_RESPONSE], debug=debug)
query.get_data(0) query.get_data(0)
carlog.warning("ecu disabled") carlog.warning("ecu disabled")

@ -217,9 +217,9 @@ class CarInterface(CarInterfaceBase):
return ret return ret
@staticmethod @staticmethod
def init(CP, logcan, sendcan): def init(CP, logcan, can_send):
if CP.carFingerprint in (HONDA_BOSCH - HONDA_BOSCH_RADARLESS) and CP.openpilotLongitudinalControl: if CP.carFingerprint in (HONDA_BOSCH - HONDA_BOSCH_RADARLESS) and CP.openpilotLongitudinalControl:
disable_ecu(logcan, sendcan, bus=1, addr=0x18DAB0F1, com_cont_req=b'\x28\x83\x03') disable_ecu(logcan, can_send, bus=1, addr=0x18DAB0F1, com_cont_req=b'\x28\x83\x03')
# returns a car.CarState # returns a car.CarState
def _update(self, c): def _update(self, c):

@ -139,16 +139,16 @@ class CarInterface(CarInterfaceBase):
return ret return ret
@staticmethod @staticmethod
def init(CP, logcan, sendcan): def init(CP, logcan, can_send):
if CP.openpilotLongitudinalControl and not (CP.flags & HyundaiFlags.CANFD_CAMERA_SCC.value): if CP.openpilotLongitudinalControl and not (CP.flags & HyundaiFlags.CANFD_CAMERA_SCC.value):
addr, bus = 0x7d0, 0 addr, bus = 0x7d0, 0
if CP.flags & HyundaiFlags.CANFD_HDA2.value: if CP.flags & HyundaiFlags.CANFD_HDA2.value:
addr, bus = 0x730, CanBus(CP).ECAN addr, bus = 0x730, CanBus(CP).ECAN
disable_ecu(logcan, sendcan, bus=bus, addr=addr, com_cont_req=b'\x28\x83\x01') disable_ecu(logcan, can_send, bus=bus, addr=addr, com_cont_req=b'\x28\x83\x01')
# for blinkers # for blinkers
if CP.flags & HyundaiFlags.ENABLE_BLINKERS: if CP.flags & HyundaiFlags.ENABLE_BLINKERS:
disable_ecu(logcan, sendcan, bus=CanBus(CP).ECAN, addr=0x7B1, com_cont_req=b'\x28\x83\x01') disable_ecu(logcan, can_send, bus=CanBus(CP).ECAN, addr=0x7B1, com_cont_req=b'\x28\x83\x01')
def _update(self, c): def _update(self, c):
ret = self.CS.update(self.cp, self.cp_cam) ret = self.CS.update(self.cp, self.cp_cam)

@ -4,6 +4,7 @@ import numpy as np
import tomllib import tomllib
from abc import abstractmethod, ABC from abc import abstractmethod, ABC
from enum import StrEnum from enum import StrEnum
from types import SimpleNamespace
from typing import Any, NamedTuple from typing import Any, NamedTuple
from collections.abc import Callable from collections.abc import Callable
from functools import cache from functools import cache
@ -12,6 +13,7 @@ from cereal import car
from openpilot.common.basedir import BASEDIR from openpilot.common.basedir import BASEDIR
from openpilot.common.simple_kalman import KF1D, get_kalman_gain 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 DT_CTRL, apply_hysteresis, gen_empty_fingerprint, scale_rot_inertia, scale_tire_stiffness, get_friction, STD_CARGO_KG
from openpilot.selfdrive.car.can_definitions import CanSendCallable
from openpilot.selfdrive.car.conversions import Conversions as CV from openpilot.selfdrive.car.conversions import Conversions as CV
from openpilot.selfdrive.car.helpers import clip from openpilot.selfdrive.car.helpers import clip
from openpilot.selfdrive.car.values import PLATFORMS from openpilot.selfdrive.car.values import PLATFORMS
@ -156,7 +158,7 @@ class CarInterfaceBase(ABC):
raise NotImplementedError raise NotImplementedError
@staticmethod @staticmethod
def init(CP, logcan, sendcan): def init(CP: car.CarParams, logcan: SimpleNamespace, can_send: CanSendCallable):
pass pass
@staticmethod @staticmethod

@ -106,6 +106,6 @@ class CarInterface(CarInterfaceBase):
return ret return ret
@staticmethod @staticmethod
def init(CP, logcan, sendcan): def init(CP, logcan, can_send):
if CP.flags & SubaruFlags.DISABLE_EYESIGHT: if CP.flags & SubaruFlags.DISABLE_EYESIGHT:
disable_ecu(logcan, sendcan, bus=2, addr=GLOBAL_ES_ADDR, com_cont_req=b'\x28\x03\x01') disable_ecu(logcan, can_send, bus=2, addr=GLOBAL_ES_ADDR, com_cont_req=b'\x28\x03\x01')

@ -138,11 +138,11 @@ class CarInterface(CarInterfaceBase):
return ret return ret
@staticmethod @staticmethod
def init(CP, logcan, sendcan): def init(CP, logcan, can_send):
# disable radar if alpha longitudinal toggled on radar-ACC car # disable radar if alpha longitudinal toggled on radar-ACC car
if CP.flags & ToyotaFlags.DISABLE_RADAR.value: if CP.flags & ToyotaFlags.DISABLE_RADAR.value:
communication_control = bytes([uds.SERVICE_TYPE.COMMUNICATION_CONTROL, uds.CONTROL_TYPE.ENABLE_RX_DISABLE_TX, uds.MESSAGE_TYPE.NORMAL]) communication_control = bytes([uds.SERVICE_TYPE.COMMUNICATION_CONTROL, uds.CONTROL_TYPE.ENABLE_RX_DISABLE_TX, uds.MESSAGE_TYPE.NORMAL])
disable_ecu(logcan, sendcan, bus=0, addr=0x750, sub_addr=0xf, com_cont_req=communication_control) disable_ecu(logcan, can_send, bus=0, addr=0x750, sub_addr=0xf, com_cont_req=communication_control)
# returns a car.CarState # returns a car.CarState
def _update(self, c): def _update(self, c):

Loading…
Cancel
Save