Skip to content

Commit

Permalink
fix tesla safety tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasloetkolben committed Oct 14, 2024
1 parent b3a1e5d commit f48e035
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions board/safety/safety_tesla.h
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/safety/test_tesla.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit f48e035

Please sign in to comment.