diff --git a/opendbc_repo/opendbc/car/gm/carcontroller.py b/opendbc_repo/opendbc/car/gm/carcontroller.py index f9beef2d4..1a0233f05 100644 --- a/opendbc_repo/opendbc/car/gm/carcontroller.py +++ b/opendbc_repo/opendbc/car/gm/carcontroller.py @@ -528,21 +528,18 @@ class CarController(CarControllerBase): if self.CP.networkLocation == NetworkLocation.gateway and self.frame % keepalive_step == 0: can_sends += gmcan.create_adas_keepalive(CanBus.POWERTRAIN) - # Pedal interceptor: continuously spam CANCEL while OP longitudinal is active. - if (self.CP.flags & GMFlags.PEDAL_LONG.value) and CC.longActive: - if self.CP.carFingerprint == CAR.CHEVROLET_MALIBU_HYBRID_CC: - malibu_cancel_requested = True - elif (self.frame - self.last_button_frame) * DT_CTRL > 0.04: - self.last_button_frame = self.frame - cancel_bus = CanBus.CAMERA if self.CP.carFingerprint == CAR.CHEVROLET_BOLT_ACC_2022_2023_PEDAL else CanBus.POWERTRAIN - can_sends.append(gmcan.create_buttons(self.packer_pt, cancel_bus, (CS.buttons_counter + 1) % 4, CruiseButtons.CANCEL)) - # CC_LONG: only send CANCEL on OP disengage while cruise is still on. - elif ( - (self.CP.flags & GMFlags.CC_LONG.value) and - self.prev_op_enabled and - not CC.enabled and - CS.out.cruiseState.enabled - ): + # - CC_LONG: cancel stock CC if OP is not active + stock_cc_active = CS.out.cruiseState.enabled or CS.pcm_acc_status != AccState.OFF + # Pedal-long cancel should only run while stock cruise is actually enabled. + # Using pcm_acc_status here causes cancel spam even after disable, which can + # intermittently knock CruiseMain off. + stock_cc_active_pedal = CS.out.cruiseState.enabled + pedal_cancel = bool(self.CP.flags & GMFlags.PEDAL_LONG.value) + if self.CP.carFingerprint == CAR.CHEVROLET_MALIBU_HYBRID_CC: + pedal_cancel = pedal_cancel and CC.longActive + + if ((pedal_cancel and stock_cc_active_pedal) or + (((self.CP.flags & GMFlags.CC_LONG.value) and not CC.enabled) and stock_cc_active)): if self.CP.carFingerprint == CAR.CHEVROLET_MALIBU_HYBRID_CC: malibu_cancel_requested = True elif (self.frame - self.last_button_frame) * DT_CTRL > 0.04: