Skip to content

Commit

Permalink
Hyundai safety: temporarily disabled button spam check to avoid camer…
Browse files Browse the repository at this point in the history
…a faults
  • Loading branch information
rbiasini committed Sep 8, 2018
1 parent 53aef76 commit 63b7926
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
7 changes: 4 additions & 3 deletions board/safety/safety_hyundai.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ static int hyundai_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
// FORCE CANCEL: safety check only relevant when spamming the cancel button.
// ensuring that only the cancel button press is sent (VAL 4) when controls are off.
// This avoids unintended engagements while still allowing resume spam
if (((to_send->RIR>>21) == 1265) && !controls_allowed && ((to_send->RDTR >> 4) & 0xFF) == 0) {
if ((to_send->RDLR & 0x7) != 4) return 0;
}
// TODO: fix bug preventing the button msg to be fwd'd on bus 2
//if (((to_send->RIR>>21) == 1265) && !controls_allowed && ((to_send->RDTR >> 4) & 0xFF) == 0) {
// if ((to_send->RDLR & 0x7) != 4) return 0;
//}

// 1 allows the message through
return true;
Expand Down
24 changes: 12 additions & 12 deletions tests/safety/test_hyundai.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,18 @@ def test_realtime_limits(self):
self.assertTrue(self.safety.hyundai_tx_hook(self._torque_msg(sign * (MAX_RT_DELTA + 1))))


def test_spam_cancel_safety_check(self):
RESUME_BTN = 1
SET_BTN = 2
CANCEL_BTN = 4
BUTTON_MSG = 1265
self.safety.set_controls_allowed(0)
self.assertTrue(self.safety.hyundai_tx_hook(self._button_msg(CANCEL_BTN)))
self.assertFalse(self.safety.hyundai_tx_hook(self._button_msg(RESUME_BTN)))
self.assertFalse(self.safety.hyundai_tx_hook(self._button_msg(SET_BTN)))
# do not block resume if we are engaged already
self.safety.set_controls_allowed(1)
self.assertTrue(self.safety.hyundai_tx_hook(self._button_msg(RESUME_BTN)))
#def test_spam_cancel_safety_check(self):
# RESUME_BTN = 1
# SET_BTN = 2
# CANCEL_BTN = 4
# BUTTON_MSG = 1265
# self.safety.set_controls_allowed(0)
# self.assertTrue(self.safety.hyundai_tx_hook(self._button_msg(CANCEL_BTN)))
# self.assertFalse(self.safety.hyundai_tx_hook(self._button_msg(RESUME_BTN)))
# self.assertFalse(self.safety.hyundai_tx_hook(self._button_msg(SET_BTN)))
# # do not block resume if we are engaged already
# self.safety.set_controls_allowed(1)
# self.assertTrue(self.safety.hyundai_tx_hook(self._button_msg(RESUME_BTN)))


if __name__ == "__main__":
Expand Down

0 comments on commit 63b7926

Please sign in to comment.