Skip to content

Commit

Permalink
Subaru: preglobal check steer req bit (#1626)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnewb1 committed Aug 31, 2023
1 parent 3efa31a commit f4d0904
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion board/safety/safety_subaru_preglobal.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ static int subaru_preglobal_tx_hook(CANPacket_t *to_send) {
int desired_torque = ((GET_BYTES(to_send, 0, 4) >> 8) & 0x1FFFU);
desired_torque = -1 * to_signed(desired_torque, 13);

if (steer_torque_cmd_checks(desired_torque, -1, SUBARU_PG_STEERING_LIMITS)) {
bool steer_req = (GET_BIT(to_send, 24U) != 0U);

if (steer_torque_cmd_checks(desired_torque, steer_req, SUBARU_PG_STEERING_LIMITS)) {
tx = 0;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/safety/test_subaru_preglobal.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _user_brake_msg(self, brake):
return self.packer.make_can_msg_panda("Brake_Pedal", 0, values)

def _torque_cmd_msg(self, torque, steer_req=1):
values = {"LKAS_Command": torque}
values = {"LKAS_Command": torque, "LKAS_Active": steer_req}
return self.packer.make_can_msg_panda("ES_LKAS", 0, values)

def _user_gas_msg(self, gas):
Expand Down

0 comments on commit f4d0904

Please sign in to comment.