From f96ce9c79035a8fe0c2ae6ab67bc3feaae171f19 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 20 Nov 2023 14:26:16 -0800 Subject: [PATCH] ford allows set... --- board/safety_declarations.h | 1 + tests/safety/test_ford.py | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/board/safety_declarations.h b/board/safety_declarations.h index 7198db7f1..6584d42d2 100644 --- a/board/safety_declarations.h +++ b/board/safety_declarations.h @@ -186,6 +186,7 @@ bool longitudinal_transmission_rpm_checks(int desired_transmission_rpm, const Lo bool longitudinal_brake_checks(int desired_brake, const LongitudinalLimits limits); bool longitudinal_interceptor_checks(CANPacket_t *to_send); void pcm_cruise_check(bool cruise_engaged); +void buttons_check(bool resume_pressed, bool set_pressed, bool cancel_pressed); typedef safety_config (*safety_hook_init)(uint16_t param); typedef void (*rx_hook)(CANPacket_t *to_push); diff --git a/tests/safety/test_ford.py b/tests/safety/test_ford.py index f174eb0fa..a2a108d2c 100755 --- a/tests/safety/test_ford.py +++ b/tests/safety/test_ford.py @@ -56,7 +56,8 @@ def checksum(msg): class Buttons: CANCEL = 0 RESUME = 1 - TJA_TOGGLE = 2 + SET = 2 + TJA_TOGGLE = 3 # Ford safety has four different configurations tested here: @@ -194,10 +195,24 @@ class TestFordSafetyBase(common.PandaCarSafetyTest): values = { "CcAslButtnCnclPress": 1 if button == Buttons.CANCEL else 0, "CcAsllButtnResPress": 1 if button == Buttons.RESUME else 0, + "CcAslButtnSetPress": 1 if button == Buttons.SET else 0, "TjaButtnOnOffPress": 1 if button == Buttons.TJA_TOGGLE else 0, } return self.packer.make_can_msg_panda("Steering_Data_FD1", bus, values) + def test_buttons(self): + for bus in (0, 2): + for controls_allowed in (True, False): + with self.subTest(bus=bus, controls_allowed=controls_allowed): + self.safety.set_controls_allowed(controls_allowed) + self.safety.set_cruise_engaged_prev(False) + self.assertFalse(self._tx(self._acc_button_msg(button=Buttons.SET, bus=bus))) + self.assertEqual(controls_allowed, self._tx(self._acc_button_msg(button=Buttons.RESUME, bus=bus))) + self.assertFalse(self._tx(self._acc_button_msg(button=Buttons.CANCEL, bus=bus))) + + self.safety.set_cruise_engaged_prev(True) + self.assertTrue(self._tx(self._acc_button_msg(button=Buttons.CANCEL, bus=bus))) + def test_rx_hook(self): # checksum, counter, and quality flag checks for quality_flag in [True, False]: