Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gregjhogan committed Oct 15, 2024
1 parent adecbac commit c8ade38
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions board/safety/safety_tesla.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/safety/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion tests/safety/test_tesla.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]}

Expand Down

0 comments on commit c8ade38

Please sign in to comment.