From c8ade380239afd3833899599ee7d8b06c6e999d4 Mon Sep 17 00:00:00 2001 From: Greg Hogan Date: Mon, 14 Oct 2024 22:59:41 -0700 Subject: [PATCH] fix tests --- board/safety/safety_tesla.h | 6 ++---- tests/safety/common.py | 2 +- tests/safety/test_tesla.py | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/board/safety/safety_tesla.h b/board/safety/safety_tesla.h index 4d663a263e..e21cd4f736 100644 --- a/board/safety/safety_tesla.h +++ b/board/safety/safety_tesla.h @@ -17,10 +17,6 @@ static void tesla_rx_hook(const CANPacket_t *to_push) { } if(bus == 0) { - if(addr == 0x286){ - vehicle_moving = ((GET_BYTE(to_push, 5) & 0x1CU) >> 2) != 3U; - } - if(addr == 0x257){ // Vehicle speed: ((val * 0.08) - 40) * KPH_TO_MPS float speed = (((((GET_BYTE(to_push, 2)) << 4) | (GET_BYTE(to_push, 1) >> 4)) * 0.08) - 40) * 0.277778; @@ -39,6 +35,8 @@ static void tesla_rx_hook(const CANPacket_t *to_push) { // Cruise state if(addr == 0x286) { + vehicle_moving = ((GET_BYTE(to_push, 5) & 0x1CU) >> 2) != 3U; + int cruise_state = ((GET_BYTE(to_push, 1) << 1 ) >> 5); bool cruise_engaged = (cruise_state == 2) || // ENABLED (cruise_state == 3) || // STANDSTILL diff --git a/tests/safety/common.py b/tests/safety/common.py index 884f21a360..8d1272a07a 100644 --- a/tests/safety/common.py +++ b/tests/safety/common.py @@ -951,8 +951,8 @@ def test_not_allow_user_brake_when_moving(self, _user_brake_msg=None, get_brake_ # Brake was already pressed self._rx(_user_brake_msg(1)) - self.safety.set_controls_allowed(1) self._rx(self._vehicle_moving_msg(self.STANDSTILL_THRESHOLD)) + self.safety.set_controls_allowed(1) self._rx(_user_brake_msg(1)) self.assertTrue(self.safety.get_controls_allowed()) self.assertTrue(self.safety.get_longitudinal_allowed()) diff --git a/tests/safety/test_tesla.py b/tests/safety/test_tesla.py index e6d5389ab8..bcfe659e7c 100755 --- a/tests/safety/test_tesla.py +++ b/tests/safety/test_tesla.py @@ -79,7 +79,7 @@ def _angle_meas_msg(self, angle: float): values = {"EPAS3S_internalSAS": angle} return self.packer.make_can_msg_panda("EPAS3S_sysStatus", 0, values) -class TestTeslaLongitudinalSafetyBase(TestTeslaSafetyBase): +class TestTeslaLongitudinalSafety(TestTeslaSafetyBase): RELAY_MALFUNCTION_ADDRS = {0: (MSG_DAS_steeringControl, MSG_APS_eacMonitor, MSG_DAS_Control)} FWD_BLACKLISTED_ADDRS = {2: [MSG_DAS_steeringControl, MSG_APS_eacMonitor, MSG_DAS_Control]}