Skip to content

Commit

Permalink
Revert "GM: enable on rising edge of resume (commaai#1155)"
Browse files Browse the repository at this point in the history
This reverts commit 5aa33e1.
  • Loading branch information
sshane committed Nov 12, 2022
1 parent 5aa33e1 commit ff48ecc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions board/safety/safety_gm.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ static int gm_rx_hook(CANPacket_t *to_push) {
controls_allowed = 0;
}

// enter controls on falling edge of set or rising edge of resume (avoids fault)
// enter controls on falling edge of set or resume
bool set = (button == GM_BTN_UNPRESS) && (cruise_button_prev == GM_BTN_SET);
bool res = (button == GM_BTN_RESUME) && (cruise_button_prev == GM_BTN_UNPRESS);
bool res = (button == GM_BTN_UNPRESS) && (cruise_button_prev == GM_BTN_RESUME);
if (set || res) {
controls_allowed = 1;
}
Expand Down
7 changes: 3 additions & 4 deletions tests/safety/test_gm.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@ class GmLongitudinalBase(common.PandaSafetyTest):

def test_set_resume_buttons(self):
"""
SET and RESUME enter controls allowed on their falling and rising edges, respectively.
SET and RESUME enter controls allowed on their falling edge.
"""
for btn in range(8):
self.safety.set_controls_allowed(0)
for _ in range(10):
self._rx(self._button_msg(btn))
should_enable = btn == Buttons.RES_ACCEL
self.assertEqual(should_enable, self.safety.get_controls_allowed())
self.assertFalse(self.safety.get_controls_allowed())

# set should enter controls allowed on falling edge, resume should maintain controls allowed
# should enter controls allowed on falling edge
if btn in (Buttons.RES_ACCEL, Buttons.DECEL_SET):
self._rx(self._button_msg(Buttons.UNPRESS))
self.assertTrue(self.safety.get_controls_allowed())
Expand Down

0 comments on commit ff48ecc

Please sign in to comment.