diff --git a/opendbc/car/tesla/carcontroller.py b/opendbc/car/tesla/carcontroller.py index 62e25c1aaf..3f87d0faea 100644 --- a/opendbc/car/tesla/carcontroller.py +++ b/opendbc/car/tesla/carcontroller.py @@ -41,7 +41,7 @@ def update(self, CC, CS, now_nanos): state = 4 if not hands_on_fault else 13 # 4=ACC_ON, 13=ACC_CANCEL_GENERIC_SILENT accel = clip(actuators.accel, CarControllerParams.ACCEL_MIN, CarControllerParams.ACCEL_MAX) cntr = (self.frame // 4) % 8 - can_sends.append(self.tesla_can.create_longitudinal_command(state, accel, cntr)) + can_sends.append(self.tesla_can.create_longitudinal_command(state, accel, cntr, CC.longActive)) # Increment counter so cancel is prioritized even without openpilot longitudinal if hands_on_fault and not self.CP.openpilotLongitudinalControl: diff --git a/opendbc/car/tesla/teslacan.py b/opendbc/car/tesla/teslacan.py index 22963861bc..ef3bcec35c 100644 --- a/opendbc/car/tesla/teslacan.py +++ b/opendbc/car/tesla/teslacan.py @@ -24,9 +24,9 @@ def create_steering_control(self, angle, enabled, counter): values["DAS_steeringControlChecksum"] = self.checksum(0x488, data[:3]) return self.packer.make_can_msg("DAS_steeringControl", CANBUS.party, values) - def create_longitudinal_command(self, acc_state, accel, cntr): + def create_longitudinal_command(self, acc_state, accel, cntr, active): values = { - "DAS_setSpeed": 0 if accel < 0 else V_CRUISE_MAX, + "DAS_setSpeed": 0 if (accel < 0 or not active) else V_CRUISE_MAX, "DAS_accState": acc_state, "DAS_aebEvent": 0, "DAS_jerkMin": CarControllerParams.JERK_LIMIT_MIN,