Skip to content

Commit

Permalink
remove can 1 from safety
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasloetkolben committed Sep 21, 2024
1 parent be0ed49 commit c31f2d4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 38 deletions.
13 changes: 1 addition & 12 deletions board/safety/safety_tesla.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const int TESLA_FLAG_LONGITUDINAL_CONTROL = 1;
const CanMsg TESLA_M3_Y_TX_MSGS[] = {
{0x488, 0, 4}, // DAS_steeringControl
{0x2b9, 0, 8}, // DAS_control
{0x229, 1, 3}, // SCCM_rightStalk
};

RxCheck tesla_model3_y_rx_checks[] = {
Expand All @@ -31,8 +30,7 @@ RxCheck tesla_model3_y_rx_checks[] = {
{.msg = {{0x118, 0, 8, .frequency = 100U}, { 0 }, { 0 }}}, // DI_systemStatus (gas pedal)
{.msg = {{0x39d, 0, 5, .frequency = 25U}, { 0 }, { 0 }}}, // IBST_status (brakes)
{.msg = {{0x286, 0, 8, .frequency = 10U}, { 0 }, { 0 }}}, // DI_state (acc state)
{.msg = {{0x311, 0, 7, .frequency = 10U}, { 0 }, { 0 }}}, // UI_warning (buckle switch & doors)
{.msg = {{0x3f5, 1, 8, .frequency = 10U}, { 0 }, { 0 }}}, // ID3F5VCFRONT_lighting (blinkers)
{.msg = {{0x311, 0, 7, .frequency = 10U}, { 0 }, { 0 }}}, // UI_warning (blinkers, buckle switch & doors)
};

bool tesla_longitudinal = false;
Expand Down Expand Up @@ -113,15 +111,6 @@ static bool tesla_tx_hook(const CANPacket_t *to_send) {
}
}


if (addr == 0x229){
// Only the "Half up" and "Neutral" positions are permitted for sending stalk signals.
int control_lever_status = ((GET_BYTE(to_send, 1) & 0x70U) >> 4);
if ((control_lever_status > 1)) {
violation = true;
}
}

if(addr == 0x2b9) {
// DAS_control: longitudinal control message
if (tesla_longitudinal) {
Expand Down
27 changes: 1 addition & 26 deletions tests/safety/test_tesla.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@

MSG_DAS_steeringControl = 0x488
MSG_DAS_Control = 0x2b9
MSG_SCCM_rightStalk = 0x229

class TestTeslaSafetyBase(common.PandaCarSafetyTest):
RELAY_MALFUNCTION_ADDRS = {0: (MSG_DAS_steeringControl,)}
FWD_BLACKLISTED_ADDRS = {2: [MSG_DAS_steeringControl]}
TX_MSGS = [[MSG_DAS_steeringControl, 0], [MSG_DAS_Control, 0], [MSG_SCCM_rightStalk, 1]]
TX_MSGS = [[MSG_DAS_steeringControl, 0], [MSG_DAS_Control, 0]]

STANDSTILL_THRESHOLD = 1
GAS_PRESSED_THRESHOLD = 3
FWD_BUS_LOOKUP = {0: 2, 2: 0}

packer: CANPackerPanda
packer_vehicle: CANPackerPanda

@classmethod
def setUpClass(cls):
Expand All @@ -46,10 +44,6 @@ def _pcm_status_msg(self, enable):
values = {"DI_cruiseState": 2 if enable else 0}
return self.packer.make_can_msg_panda("DI_state", 0, values)

def _control_lever_cmd(self, command):
values = {"SCCM_rightStalkStatus": command}
return self.packer_vehicle.make_can_msg_panda("SCCM_rightStalk", 1, values)

def _long_control_msg(self, set_speed, acc_val=0, jerk_limits=(0, 0), accel_limits=(0, 0), aeb_event=0, bus=0):
values = {
"DAS_setSpeed": set_speed,
Expand All @@ -72,7 +66,6 @@ class TestTeslaStockSafety(TestTeslaSafetyBase):

def setUp(self):
self.packer = CANPackerPanda("tesla_model3_party")
self.packer_vehicle = CANPackerPanda("tesla_model3_vehicle")
self.safety = libpanda_py.libpanda
self.safety.set_safety_hooks(Panda.SAFETY_TESLA, 0)
self.safety.init_tests()
Expand All @@ -85,23 +78,6 @@ def _angle_meas_msg(self, angle: float):
values = {"EPAS3S_internalSAS": angle}
return self.packer.make_can_msg_panda("EPAS3S_sysStatus", 0, values)

def test_acc_buttons(self):
"""
cancel & idle allowed.
"""
btns = [
(0, True), # IDLE
(1, True), # HALF UP
(2, False), # FULL UP
(3, False), # HALF DOWN
(4, False), # FULL DOWN
]
for btn, should_tx in btns:
for controls_allowed in (True, False):
self.safety.set_controls_allowed(controls_allowed)
tx = self._tx(self._control_lever_cmd(btn))
self.assertEqual(tx, should_tx)

class TestTeslaLongitudinalSafetyBase(TestTeslaSafetyBase):
RELAY_MALFUNCTION_ADDRS = {0: (MSG_DAS_steeringControl, MSG_DAS_Control)}
FWD_BLACKLISTED_ADDRS = {2: [MSG_DAS_steeringControl, MSG_DAS_Control]}
Expand All @@ -112,7 +88,6 @@ class TestTeslaLongitudinalSafetyBase(TestTeslaSafetyBase):

def setUp(self):
self.packer = CANPackerPanda("tesla_model3_party")
self.packer_vehicle = CANPackerPanda("tesla_model3_vehicle")
self.safety = libpanda_py.libpanda
self.safety.set_safety_hooks(Panda.SAFETY_TESLA, Panda.FLAG_TESLA_LONG_CONTROL)
self.safety.init_tests()
Expand Down

0 comments on commit c31f2d4

Please sign in to comment.