This commit is contained in:
Shane Smiskol 2023-11-20 15:04:38 -08:00
parent 8ec4e55b47
commit 161d7fdd59
3 changed files with 17 additions and 5 deletions

View File

@ -695,6 +695,20 @@ bool steer_angle_cmd_checks(int desired_angle, bool steer_control_enabled, const
return violation;
}
bool button_checks(bool resume_pressed, bool set_pressed, bool cancel_pressed, bool pcm_cruise) {
UNUSED(pcm_cruise);
UNUSED(set_pressed); // todo: this should never be sent
bool allowed_cancel = cancel_pressed && cruise_engaged_prev;
bool allowed_resume = resume_pressed && controls_allowed;
bool violation = false;
if (!(allowed_resume || allowed_cancel)) {
violation = true;
}
return violation;
}
void pcm_cruise_check(bool cruise_engaged) {
// Enter controls on rising edge of stock ACC, exit controls if stock ACC disengages
if (!cruise_engaged) {

View File

@ -296,13 +296,11 @@ static bool ford_tx_hook(CANPacket_t *to_send) {
if (addr == FORD_Steering_Data_FD1) {
// Violation if resume button is pressed while controls not allowed, or
// if cancel button is pressed when cruise isn't engaged.
bool allowed_cancel = (GET_BIT(to_send, 8U) == 1U) && cruise_engaged_prev;
bool allowed_resume = (GET_BIT(to_send, 25U) == 1U) && controls_allowed;
if (!(allowed_resume || allowed_cancel)) {
if (button_checks((GET_BIT(to_send, 25U) == 1U), false, (GET_BIT(to_send, 8U) == 1U), true)) {
tx = 0;
}
// bool violation = false;
// violation |= (GET_BIT(to_send, 8U) == 1U) && !cruise_engaged_prev; // Signal: CcAslButtnCnclPress (cancel)
// violation |= (GET_BIT(to_send, 25U) == 1U) && !controls_allowed; // Signal: CcAsllButtnResPress (resume)

View File

@ -185,8 +185,8 @@ bool longitudinal_gas_checks(int desired_gas, const LongitudinalLimits limits);
bool longitudinal_transmission_rpm_checks(int desired_transmission_rpm, const LongitudinalLimits limits);
bool longitudinal_brake_checks(int desired_brake, const LongitudinalLimits limits);
bool longitudinal_interceptor_checks(CANPacket_t *to_send);
bool button_checks(bool resume_pressed, bool set_pressed, bool cancel_pressed, bool pcm_cruise);
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);