Hyundai safety: temporarily disabled button spam check to avoid camera faults

master
Riccardo 2018-09-07 20:43:13 -07:00
parent 53aef76cf1
commit 63b7926364
2 changed files with 16 additions and 15 deletions

View File

@ -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;

View File

@ -168,18 +168,18 @@ class TestHyundaiSafety(unittest.TestCase):
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__":