From 07a4bfc5f5d5fbb27031a0ed030387d02e260ace Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Wed, 8 Apr 2026 21:51:17 -0500 Subject: [PATCH] 0x370 Leak --- opendbc_repo/opendbc/car/gm/carcontroller.py | 19 +++++++++++++++++-- opendbc_repo/opendbc/car/gm/tests/test_gm.py | 15 +++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/opendbc_repo/opendbc/car/gm/carcontroller.py b/opendbc_repo/opendbc/car/gm/carcontroller.py index 0fe8868e..0c31ba2b 100644 --- a/opendbc_repo/opendbc/car/gm/carcontroller.py +++ b/opendbc_repo/opendbc/car/gm/carcontroller.py @@ -36,6 +36,20 @@ def use_interceptor_sng_launch(CP, CS, maneuver_mode=False): return CS.out.cruiseState.standstill and (CS.out.standstill or CS.out.vEgo < launch_speed) +def should_spoof_dash_speed(CP, starpilot_toggles): + if not CP.openpilotLongitudinalControl: + return False + + # Respect the current StarPilot stock-ACC toggles even before CarParams are + # rebuilt on reboot, so the cluster speed spoof doesn't leak in stock mode. + if getattr(starpilot_toggles, "disable_openpilot_long", False): + return False + if CP.enableGasInterceptorDEPRECATED and not getattr(starpilot_toggles, "gm_pedal_longitudinal", True): + return False + + return True + + class CarController(CarControllerBase): def __init__(self, dbc_names, CP): super().__init__(dbc_names, CP) @@ -283,6 +297,7 @@ class CarController(CarControllerBase): hud_v_cruise = hud_control.setSpeed if hud_v_cruise > 70: hud_v_cruise = 0 + dash_speed_spoof_active = should_spoof_dash_speed(self.CP, starpilot_toggles) # Send CAN commands. can_sends = [] @@ -366,7 +381,7 @@ class CarController(CarControllerBase): self.CP.carFingerprint in spoof_ecm_cruise_cars and self.CP.enableGasInterceptorDEPRECATED ) - if non_acc_pedal_long and self.frame % 4 == 0: + if non_acc_pedal_long and dash_speed_spoof_active and self.frame % 4 == 0: can_sends.append(gmcan.create_ecm_cruise_control_command( self.packer_pt, CanBus.POWERTRAIN, True, hud_v_cruise * CV.MS_TO_KPH)) @@ -518,7 +533,7 @@ class CarController(CarControllerBase): idx, CC.enabled, near_stop, at_full_stop, self.CP)) is_bolt_acc_pedal = self.CP.carFingerprint == CAR.CHEVROLET_BOLT_ACC_2022_2023_PEDAL - if self.CP.carFingerprint not in CC_ONLY_CAR or is_bolt_acc_pedal: + if dash_speed_spoof_active and (self.CP.carFingerprint not in CC_ONLY_CAR or is_bolt_acc_pedal): send_fcw = hud_alert == VisualAlert.fcw can_sends.append(gmcan.create_acc_dashboard_command(self.packer_pt, CanBus.POWERTRAIN, CC.enabled, hud_v_cruise * CV.MS_TO_KPH, hud_control, send_fcw)) diff --git a/opendbc_repo/opendbc/car/gm/tests/test_gm.py b/opendbc_repo/opendbc/car/gm/tests/test_gm.py index 0301f664..828c08a2 100644 --- a/opendbc_repo/opendbc/car/gm/tests/test_gm.py +++ b/opendbc_repo/opendbc/car/gm/tests/test_gm.py @@ -3,6 +3,7 @@ from types import SimpleNamespace from parameterized import parameterized from opendbc.car.car_helpers import interfaces +from opendbc.car.gm.carcontroller import should_spoof_dash_speed import opendbc.car.gm.interface as gm_interface from opendbc.car.common.conversions import Conversions as CV from opendbc.car.gm.fingerprints import FINGERPRINTS @@ -71,3 +72,17 @@ class TestGMInterface: assert list(car_params.longitudinalTuning.kiV) == [0.025, 0.035, 0.055, 0.08] assert car_params.startingState assert car_params.startAccel == pytest.approx(1.15) + + +class TestGMCarController: + def test_dash_speed_spoof_respects_live_stock_acc_toggles(self): + cp = SimpleNamespace(openpilotLongitudinalControl=True, enableGasInterceptorDEPRECATED=True) + + assert should_spoof_dash_speed(cp, SimpleNamespace(disable_openpilot_long=False, gm_pedal_longitudinal=True)) + assert not should_spoof_dash_speed(cp, SimpleNamespace(disable_openpilot_long=True, gm_pedal_longitudinal=True)) + assert not should_spoof_dash_speed(cp, SimpleNamespace(disable_openpilot_long=False, gm_pedal_longitudinal=False)) + + def test_dash_speed_spoof_allows_non_pedal_long_when_op_long_enabled(self): + cp = SimpleNamespace(openpilotLongitudinalControl=True, enableGasInterceptorDEPRECATED=False) + + assert should_spoof_dash_speed(cp, SimpleNamespace(disable_openpilot_long=False))