ford allows set...

This commit is contained in:
Shane Smiskol 2023-11-20 14:26:16 -08:00
parent c345bc3cae
commit f96ce9c790
2 changed files with 17 additions and 1 deletions

View File

@ -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);

View File

@ -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]: