diff --git a/board/safety/safety_gm.h b/board/safety/safety_gm.h index 038bfe723..c9560d5ab 100644 --- a/board/safety/safety_gm.h +++ b/board/safety/safety_gm.h @@ -51,6 +51,7 @@ enum { }; enum {GM_ASCM, GM_CAM} gm_hw = GM_ASCM; +bool gm_pcm_cruise = false; static int gm_rx_hook(CANPacket_t *to_push) { @@ -73,7 +74,7 @@ static int gm_rx_hook(CANPacket_t *to_push) { } // ACC steering wheel buttons (GM_CAM is tied to the PCM) - if ((addr == 481) && (gm_hw == GM_ASCM)) { + if ((addr == 481) && !gm_pcm_cruise) { int button = (GET_BYTE(to_push, 5) & 0x70U) >> 4; // exit controls on cancel press @@ -101,7 +102,7 @@ static int gm_rx_hook(CANPacket_t *to_push) { gas_pressed = GET_BYTE(to_push, 5) != 0U; // enter controls on rising edge of ACC, exit controls when ACC off - if (gm_hw == GM_CAM) { + if (gm_pcm_cruise) { bool cruise_engaged = (GET_BYTE(to_push, 1) >> 5) != 0U; pcm_cruise_check(cruise_engaged); } @@ -234,7 +235,7 @@ static int gm_tx_hook(CANPacket_t *to_send, bool longitudinal_allowed) { } // BUTTONS: used for resume spamming and cruise cancellation with stock longitudinal - if ((addr == 481) && (gm_hw == GM_CAM)) { + if ((addr == 481) && gm_pcm_cruise) { int button = (GET_BYTE(to_send, 5) >> 4) & 0x7U; bool allowed_cancel = (button == 6) && cruise_engaged_prev; @@ -271,6 +272,7 @@ static int gm_fwd_hook(int bus_num, CANPacket_t *to_fwd) { static const addr_checks* gm_init(uint16_t param) { gm_hw = GET_FLAG(param, GM_PARAM_HW_CAM) ? GM_CAM : GM_ASCM; + gm_pcm_cruise = gm_hw == GM_CAM; return &gm_rx_checks; }