Skip to content

Commit

Permalink
Honda Radarless: forward buttons when disengaged
Browse files Browse the repository at this point in the history
  • Loading branch information
csouers committed Feb 22, 2024
1 parent 70578a1 commit 484ed5a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 6 additions & 2 deletions board/safety/safety_honda.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ static bool honda_tx_hook(const 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
// 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;
Expand Down Expand Up @@ -462,7 +462,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 && !honda_bosch_long;
if (!block_msg) {
bus_fwd = 2;
}
}
if (bus_num == 2) {
bool is_lkas_msg = (addr == 0xE4) || (addr == 0xE5) || (addr == 0x33D) || (addr == 0x33DA) || (addr == 0x33DB);
Expand Down
13 changes: 13 additions & 0 deletions tests/safety/test_honda.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,19 @@ def setUp(self):
self.safety.set_safety_hooks(Panda.SAFETY_HONDA_BOSCH, Panda.FLAG_HONDA_RADARLESS)
self.safety.init_tests()

# Test Add-on. Radarless must be able to send all buttons when controls_allowed
def test_spam_cancel_safety_check(self):
super().test_spam_cancel_safety_check()
for button in (Btn.MAIN, Btn.SET, Btn.NONE):
self.assertTrue(self._tx(self._button_msg(button, bus=self.BUTTONS_BUS)))

# Test that buttons don't forward when engaged.
def test_button_fwd_radarless(self):
self.safety.set_controls_allowed(True)
self.FWD_BLACKLISTED_ADDRS[0] = [0x296]
super().test_fwd_hook()
# reset for the following iterations
self.FWD_BLACKLISTED_ADDRS[0] = []

class TestHondaBoschRadarlessAltBrakeSafety(HondaPcmEnableBase, TestHondaBoschRadarlessSafetyBase, TestHondaBoschAltBrakeSafetyBase):
"""
Expand Down

0 comments on commit 484ed5a

Please sign in to comment.