Skip to content

Commit f214298

Browse files
committedDec 15, 2023
Honda radarless: forward buttons only when disengaged
1 parent a88fe8c commit f214298

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed
 

‎board/safety/safety_honda.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,8 @@ static bool honda_tx_hook(CANPacket_t *to_send) {
333333
}
334334
}
335335

336-
// FORCE CANCEL: safety check only relevant when spamming the cancel button in Bosch HW
337-
// ensuring that only the cancel button press is sent (VAL 2) when controls are off.
338-
// This avoids unintended engagements while still allowing resume spam
336+
// FORCE CANCEL: safety check for Bosch HW ensuring that only the cancel button press is sent (VAL 2) when
337+
// controls are off. This avoids unintended engagements while still allowing resume spam and button passthrough.
339338
if ((addr == 0x296) && !controls_allowed && (bus == bus_buttons)) {
340339
if (((GET_BYTE(to_send, 0) >> 5) & 0x7U) != 2U) {
341340
tx = false;
@@ -429,7 +428,11 @@ static int honda_bosch_fwd_hook(int bus_num, int addr) {
429428
int bus_fwd = -1;
430429

431430
if (bus_num == 0) {
432-
bus_fwd = 2;
431+
int is_button_msg = (addr == 0x296);
432+
bool block_msg = is_button_msg && controls_allowed && honda_bosch_radarless;
433+
if (!block_msg) {
434+
bus_fwd = 2;
435+
}
433436
}
434437
if (bus_num == 2) {
435438
int is_lkas_msg = (addr == 0xE4) || (addr == 0xE5) || (addr == 0x33D) || (addr == 0x33DA) || (addr == 0x33DB);

‎tests/safety/test_honda.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -437,14 +437,13 @@ def test_alt_disengage_on_brake(self):
437437
self._rx(self._alt_brake_msg(1))
438438
self.assertTrue(self.safety.get_controls_allowed())
439439

440+
# Allow any button if we are engaged. Only allow cancel when disengaged.
440441
def test_spam_cancel_safety_check(self):
441-
self.safety.set_controls_allowed(0)
442-
self.assertTrue(self._tx(self._button_msg(Btn.CANCEL, bus=self.BUTTONS_BUS)))
443-
self.assertFalse(self._tx(self._button_msg(Btn.RESUME, bus=self.BUTTONS_BUS)))
444-
self.assertFalse(self._tx(self._button_msg(Btn.SET, bus=self.BUTTONS_BUS)))
445-
# do not block resume if we are engaged already
446-
self.safety.set_controls_allowed(1)
447-
self.assertTrue(self._tx(self._button_msg(Btn.RESUME, bus=self.BUTTONS_BUS)))
442+
for controls_allowed in [False, True]:
443+
self.safety.set_controls_allowed(controls_allowed)
444+
self.assertTrue(self._tx(self._button_msg(Btn.CANCEL, bus=self.BUTTONS_BUS)))
445+
for button in (Btn.MAIN, Btn.RESUME, Btn.SET, Btn.NONE):
446+
self.assertEqual(controls_allowed, self._tx(self._button_msg(button, bus=self.BUTTONS_BUS)))
448447

449448

450449
class TestHondaBoschAltBrakeSafetyBase(TestHondaBoschSafetyBase):
@@ -565,6 +564,12 @@ def setUp(self):
565564
self.safety.set_safety_hooks(Panda.SAFETY_HONDA_BOSCH, Panda.FLAG_HONDA_RADARLESS)
566565
self.safety.init_tests()
567566

567+
# Test that buttons only forward when disengaged
568+
def test_button_fwd_radarless(self):
569+
self.safety.set_controls_allowed(True)
570+
self.FWD_BLACKLISTED_ADDRS[0] = [0x296]
571+
super().test_fwd_hook()
572+
self.FWD_BLACKLISTED_ADDRS[0] = []
568573

569574
class TestHondaBoschRadarlessAltBrakeSafety(HondaPcmEnableBase, TestHondaBoschRadarlessSafetyBase, TestHondaBoschAltBrakeSafetyBase):
570575
"""

0 commit comments

Comments
 (0)