From dff6f898a8f0610c5558d70de1c25ff4ee4d7894 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Fri, 29 May 2026 12:05:02 -0500 Subject: [PATCH] done goofed --- .../opendbc/car/hyundai/tests/test_hyundai.py | 40 +++++++++++++++++++ opendbc_repo/opendbc/car/interfaces.py | 2 +- selfdrive/car/card.py | 2 +- selfdrive/car/cruise.py | 4 +- selfdrive/car/tests/test_cruise_speed.py | 2 +- 5 files changed, 46 insertions(+), 4 deletions(-) diff --git a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py index e1aee5570..649c00c0f 100644 --- a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py +++ b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py @@ -336,6 +336,46 @@ class TestHyundaiFingerprint: assert canfd_alt_buttons_cp.flags & HyundaiFlags.CANFD_ALT_BUTTONS assert not canfd_alt_buttons_fpcp.redneckCruiseAvailable + def test_hyundai_full_long_keeps_redneck_cruise_disabled(self, monkeypatch): + class FakeParams: + def __init__(self, *args, **kwargs): + pass + + @staticmethod + def get_bool(key): + return key == "RedneckCruise" + + toggles = get_test_toggles() + monkeypatch.setattr("opendbc.car.interfaces.Params", FakeParams) + + for candidate in (CAR.HYUNDAI_SONATA, CAR.KIA_FORTE): + CP = CarInterface.get_params(candidate, gen_empty_fingerprint(), [], True, False, False, toggles) + FPCP = CarInterface.get_starpilot_params(candidate, gen_empty_fingerprint(), [], CP, toggles) + + assert CP.openpilotLongitudinalControl + assert not FPCP.redneckCruiseAvailable + assert FPCP.pcmCruiseSpeed + + def test_hyundai_scc_stock_long_keeps_redneck_cruise_disabled(self, monkeypatch): + class FakeParams: + def __init__(self, *args, **kwargs): + pass + + @staticmethod + def get_bool(key): + return key == "RedneckCruise" + + toggles = get_test_toggles() + monkeypatch.setattr("opendbc.car.interfaces.Params", FakeParams) + + for candidate in (CAR.HYUNDAI_SONATA, CAR.KIA_FORTE, CAR.HYUNDAI_IONIQ_6): + CP = CarInterface.get_params(candidate, gen_empty_fingerprint(), [], False, False, False, toggles) + FPCP = CarInterface.get_starpilot_params(candidate, gen_empty_fingerprint(), [], CP, toggles) + + assert not CP.openpilotLongitudinalControl + assert not FPCP.redneckCruiseAvailable + assert FPCP.pcmCruiseSpeed + def test_palisade_2023_pause_resume_button_maps_to_enable(self): toggles = get_test_toggles() CP = CarInterface.get_params(CAR.HYUNDAI_PALISADE_2023, gen_empty_fingerprint(), [], True, False, False, toggles) diff --git a/opendbc_repo/opendbc/car/interfaces.py b/opendbc_repo/opendbc/car/interfaces.py index 27b263f2c..61b10d0f2 100644 --- a/opendbc_repo/opendbc/car/interfaces.py +++ b/opendbc_repo/opendbc/car/interfaces.py @@ -228,7 +228,7 @@ class CarInterfaceBase(ABC): if 0x1FA in fingerprint[CAN.ECAN]: fp_ret.flags |= HyundaiStarPilotFlags.SPEED_LIMIT_AVAILABLE.value - fp_ret.redneckCruiseAvailable = not bool(CP.flags & HyundaiFlags.CANFD_ALT_BUTTONS) + fp_ret.redneckCruiseAvailable = bool(CP.flags & HyundaiFlags.NON_SCC) and not bool(CP.flags & HyundaiFlags.CANFD_ALT_BUTTONS) if fp_ret.redneckCruiseAvailable and Params(return_defaults=True).get_bool("RedneckCruise") and \ not CP.openpilotLongitudinalControl: fp_ret.pcmCruiseSpeed = False diff --git a/selfdrive/car/card.py b/selfdrive/car/card.py index cc8e9eaa6..024d79445 100644 --- a/selfdrive/car/card.py +++ b/selfdrive/car/card.py @@ -168,7 +168,7 @@ class Car: self.mock_carstate = MockCarState() self.v_cruise_helper = VCruiseHelper(self.CP, self.FPCP) - self.redneck_cruise = RedneckCruise(self.CP, self.FPCP) if self.CP.brand == "hyundai" else None + self.redneck_cruise = RedneckCruise(self.CP, self.FPCP) if self.CP.brand == "hyundai" and self.FPCP.redneckCruiseAvailable and not self.FPCP.pcmCruiseSpeed else None self.redneck_button_event_filter_frames = { int(ButtonType.accelCruise): 0, int(ButtonType.decelCruise): 0, diff --git a/selfdrive/car/cruise.py b/selfdrive/car/cruise.py index 32f9367c6..29d5f1116 100644 --- a/selfdrive/car/cruise.py +++ b/selfdrive/car/cruise.py @@ -41,7 +41,9 @@ class VCruiseHelper: self.button_change_states = {btn: {"standstill": False, "enabled": False} for btn in self.button_timers} self.gm_cc_only = self.CP.carFingerprint in CC_ONLY_CAR and self.CP.flags & GMFlags.CC_LONG.value - self.redneck_non_pcm = bool(FPCP is not None and not getattr(FPCP, "pcmCruiseSpeed", True)) + self.redneck_non_pcm = bool(FPCP is not None and + getattr(FPCP, "redneckCruiseAvailable", False) and + not getattr(FPCP, "pcmCruiseSpeed", True)) def _get_short_press_delta(self, is_metric, starpilot_toggles: SimpleNamespace) -> float: base_delta = 1. if is_metric else IMPERIAL_INCREMENT diff --git a/selfdrive/car/tests/test_cruise_speed.py b/selfdrive/car/tests/test_cruise_speed.py index 9fe8251b7..5a201f8bc 100644 --- a/selfdrive/car/tests/test_cruise_speed.py +++ b/selfdrive/car/tests/test_cruise_speed.py @@ -309,7 +309,7 @@ class TestVCruiseHelper: class TestVCruiseHelperRedneck: def setup_method(self): self.CP = car.CarParams(pcmCruise=True) - self.FPCP = SimpleNamespace(pcmCruiseSpeed=False) + self.FPCP = SimpleNamespace(pcmCruiseSpeed=False, redneckCruiseAvailable=True) self.v_cruise_helper = VCruiseHelper(self.CP, self.FPCP) self.starpilot_toggles = SimpleNamespace( cruise_increase=1,