@@ -437,14 +437,13 @@ def test_alt_disengage_on_brake(self):
437
437
self ._rx (self ._alt_brake_msg (1 ))
438
438
self .assertTrue (self .safety .get_controls_allowed ())
439
439
440
+ # Allow any button if we are engaged. Only allow cancel when disengaged.
440
441
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 )))
448
447
449
448
450
449
class TestHondaBoschAltBrakeSafetyBase (TestHondaBoschSafetyBase ):
@@ -565,6 +564,12 @@ def setUp(self):
565
564
self .safety .set_safety_hooks (Panda .SAFETY_HONDA_BOSCH , Panda .FLAG_HONDA_RADARLESS )
566
565
self .safety .init_tests ()
567
566
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 ] = []
568
573
569
574
class TestHondaBoschRadarlessAltBrakeSafety (HondaPcmEnableBase , TestHondaBoschRadarlessSafetyBase , TestHondaBoschAltBrakeSafetyBase ):
570
575
"""
0 commit comments