From f48e035aec85087b41e6f04effb40dbd60667cdf Mon Sep 17 00:00:00 2001 From: lukasloetkolben <61192133+lukasloetkolben@users.noreply.github.com> Date: Mon, 14 Oct 2024 14:28:30 -0700 Subject: [PATCH] fix tesla safety tests --- board/safety/safety_tesla.h | 4 ++-- tests/safety/test_tesla.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/board/safety/safety_tesla.h b/board/safety/safety_tesla.h index 8b0ab0c584..d0996a7bca 100644 --- a/board/safety/safety_tesla.h +++ b/board/safety/safety_tesla.h @@ -18,7 +18,7 @@ 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) != 3; + vehicle_moving = ((GET_BYTE(to_push, 5) & 0x1CU) >> 2) != 3U; } if(addr == 0x257){ @@ -120,7 +120,7 @@ static bool tesla_tx_hook(const CANPacket_t *to_send) { int raw_accel_min = ((GET_BYTE(to_send, 5) & 0x0FU) << 5) | (GET_BYTE(to_send, 4) >> 3); // Prevent both acceleration from being negative, as this could cause the car to reverse after coming to standstill - if (raw_accel_max < TESLA_LONG_LIMITS.inactive_accel && raw_accel_min < TESLA_LONG_LIMITS.inactive_accel){ + if ((raw_accel_max < TESLA_LONG_LIMITS.inactive_accel) && (raw_accel_min < TESLA_LONG_LIMITS.inactive_accel)){ violation = true; } diff --git a/tests/safety/test_tesla.py b/tests/safety/test_tesla.py index f7ea800419..348a38dac5 100755 --- a/tests/safety/test_tesla.py +++ b/tests/safety/test_tesla.py @@ -33,8 +33,8 @@ def _speed_msg(self, speed): return self.packer.make_can_msg_panda("DI_speed", 0, values) def _vehicle_moving_msg(self, speed: float): - values = {"ESP_vehicleStandstillSts": 1 if speed <= self.STANDSTILL_THRESHOLD else 0} - return self.packer.make_can_msg_panda("ESP_B", 0, values) + values = {"DI_vehicleHoldState": 3 if speed <= self.STANDSTILL_THRESHOLD else 0} + return self.packer.make_can_msg_panda("DI_state", 0, values) def _user_gas_msg(self, gas): values = {"DI_accelPedalPos": gas}