diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 8e75c8e9c2c..4c56988896c 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -353,9 +353,8 @@ static bool honda_tx_hook(CANPacket_t *to_send) { } } - // FORCE CANCEL: safety check only relevant when spamming the cancel button in Bosch HW - // ensuring that only the cancel button press is sent (VAL 2) when controls are off. - // This avoids unintended engagements while still allowing resume spam + // FORCE CANCEL: safety check for Bosch HW ensuring that only the cancel button press is sent (VAL 2) when + // controls are off. This avoids unintended engagements while still allowing resume spam and button passthrough. if ((addr == 0x296) && !controls_allowed && (bus == bus_buttons)) { if (((GET_BYTE(to_send, 0) >> 5) & 0x7U) != 2U) { tx = false; @@ -458,7 +457,11 @@ static int honda_bosch_fwd_hook(int bus_num, int addr) { int bus_fwd = -1; if (bus_num == 0) { - bus_fwd = 2; + int is_button_msg = (addr == 0x296); + bool block_msg = is_button_msg && controls_allowed && honda_bosch_radarless; + if (!block_msg) { + bus_fwd = 2; + } } if (bus_num == 2) { int is_lkas_msg = (addr == 0xE4) || (addr == 0xE5) || (addr == 0x33D) || (addr == 0x33DA) || (addr == 0x33DB); diff --git a/tests/safety/test_honda.py b/tests/safety/test_honda.py index 08d069b5ed8..e11b0f7d380 100755 --- a/tests/safety/test_honda.py +++ b/tests/safety/test_honda.py @@ -451,14 +451,13 @@ def test_alt_disengage_on_brake(self): self._rx(self._alt_brake_msg(1)) self.assertTrue(self.safety.get_controls_allowed()) + # Allow any button if we are engaged. Only allow cancel when disengaged. def test_spam_cancel_safety_check(self): - self.safety.set_controls_allowed(0) - self.assertTrue(self._tx(self._button_msg(Btn.CANCEL, bus=self.BUTTONS_BUS))) - self.assertFalse(self._tx(self._button_msg(Btn.RESUME, bus=self.BUTTONS_BUS))) - self.assertFalse(self._tx(self._button_msg(Btn.SET, bus=self.BUTTONS_BUS))) - # do not block resume if we are engaged already - self.safety.set_controls_allowed(1) - self.assertTrue(self._tx(self._button_msg(Btn.RESUME, bus=self.BUTTONS_BUS))) + for controls_allowed in [False, True]: + self.safety.set_controls_allowed(controls_allowed) + self.assertTrue(self._tx(self._button_msg(Btn.CANCEL, bus=self.BUTTONS_BUS))) + for button in (Btn.MAIN, Btn.RESUME, Btn.SET, Btn.NONE): + self.assertEqual(controls_allowed, self._tx(self._button_msg(button, bus=self.BUTTONS_BUS))) class TestHondaBoschAltBrakeSafetyBase(TestHondaBoschSafetyBase): @@ -579,6 +578,12 @@ def setUp(self): self.safety.set_safety_hooks(Panda.SAFETY_HONDA_BOSCH, Panda.FLAG_HONDA_RADARLESS) self.safety.init_tests() + # Test that buttons only forward when disengaged + def test_button_fwd_radarless(self): + self.safety.set_controls_allowed(True) + self.FWD_BLACKLISTED_ADDRS[0] = [0x296] + super().test_fwd_hook() + self.FWD_BLACKLISTED_ADDRS[0] = [] class TestHondaBoschRadarlessAltBrakeSafety(HondaPcmEnableBase, TestHondaBoschRadarlessSafetyBase, TestHondaBoschAltBrakeSafetyBase): """