From 55f110351e6d5639aa4d851766996c41b6e3b8d4 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Thu, 21 May 2026 10:00:09 -0500 Subject: [PATCH] elantra hybrid --- opendbc_repo/opendbc/car/hyundai/carstate.py | 14 ++++++------ .../opendbc/car/hyundai/tests/test_hyundai.py | 22 +++++++++++++++++++ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/opendbc_repo/opendbc/car/hyundai/carstate.py b/opendbc_repo/opendbc/car/hyundai/carstate.py index 5d0449cfb..9576da743 100644 --- a/opendbc_repo/opendbc/car/hyundai/carstate.py +++ b/opendbc_repo/opendbc/car/hyundai/carstate.py @@ -27,12 +27,12 @@ IONIQ_6_BLINDSPOT_LEFT_MASK = 0x10 CANFD_CAMERA_LEAD_MIN_DISTANCE = 0.1 -def get_non_scc_cruise_signals(CP) -> tuple[str, str, str, str, str]: +def get_non_scc_cruise_signals(CP) -> tuple[str, str, str, str, str, str]: if CP.flags & HyundaiFlags.EV: - return "LABEL11", "CC_React", "CC_ACT", "E_EMS11", "Cruise_Limit_Target" + return "LABEL11", "CC_React", "EMS12", "ACC_ACT", "E_EMS11", "Cruise_Limit_Target" if CP.flags & HyundaiFlags.HYBRID: - return "E_CRUISE_CONTROL", "CRUISE_LAMP_M", "CRUISE_LAMP_S", "ELECT_GEAR", "SLC_SET_SPEED" - return "EMS16", "CRUISE_LAMP_M", "CRUISE_LAMP_S", "LVR12", "CF_Lvr_CruiseSet" + return "EMS16", "CRUISE_LAMP_M", "EMS16", "CRUISE_LAMP_S", "ELECT_GEAR", "SLC_SET_SPEED" + return "EMS16", "CRUISE_LAMP_M", "EMS16", "CRUISE_LAMP_S", "LVR12", "CF_Lvr_CruiseSet" def calculate_canfd_speed_limit(CP, FPCP, cp, cp_cam, speed_factor): @@ -224,9 +224,9 @@ class CarState(CarStateBase): ret.cruiseState.standstill = False ret.cruiseState.nonAdaptive = False elif no_scc: - cruise_msg, cruise_available_sig, cruise_enabled_sig, cruise_speed_msg, cruise_speed_sig = get_non_scc_cruise_signals(self.CP) - ret.cruiseState.available = cp.vl[cruise_msg][cruise_available_sig] != 0 - ret.cruiseState.enabled = cp.vl[cruise_msg][cruise_enabled_sig] != 0 + cruise_available_msg, cruise_available_sig, cruise_enabled_msg, cruise_enabled_sig, cruise_speed_msg, cruise_speed_sig = get_non_scc_cruise_signals(self.CP) + ret.cruiseState.available = cp.vl[cruise_available_msg][cruise_available_sig] != 0 + ret.cruiseState.enabled = cp.vl[cruise_enabled_msg][cruise_enabled_sig] != 0 ret.cruiseState.standstill = False ret.cruiseState.nonAdaptive = False ret.cruiseState.speed = cp.vl[cruise_speed_msg][cruise_speed_sig] * speed_conv diff --git a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py index f458a7b6a..13bab758a 100644 --- a/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py +++ b/opendbc_repo/opendbc/car/hyundai/tests/test_hyundai.py @@ -136,6 +136,28 @@ class TestHyundaiFingerprint: g70_2021 = CarInterface.get_params(CAR.GENESIS_G70_2021_NON_SCC, gen_empty_fingerprint(), [], True, False, False, None) assert g70_2021.flags & HyundaiFlags.NON_SCC_RADAR_FCA + @pytest.mark.parametrize(("candidate", "expected_msgs", "unexpected_msgs"), [ + (CAR.HYUNDAI_ELANTRA_2022_NON_SCC, ("EMS16", "LVR12"), ()), + (CAR.HYUNDAI_ELANTRA_HEV_2022_NON_SCC, ("EMS16", "ELECT_GEAR"), ("E_CRUISE_CONTROL",)), + (CAR.HYUNDAI_KONA_EV_NON_SCC, ("LABEL11", "EMS12", "E_EMS11"), ()), + ]) + def test_non_scc_cruise_message_selection(self, candidate, expected_msgs, unexpected_msgs): + toggles = get_test_toggles() + CP = CarInterface.get_params(candidate, gen_empty_fingerprint(), [], True, False, False, toggles) + FPCP = CarInterface.get_starpilot_params(candidate, gen_empty_fingerprint(), [], CP, toggles) + + car_state = CarState(CP, FPCP) + can_parsers = car_state.get_can_parsers(CP) + + ret, _ = car_state.update(can_parsers, toggles) + pt_states = {state.name for state in can_parsers[Bus.pt].message_states.values()} + + assert set(expected_msgs).issubset(pt_states) + assert set(unexpected_msgs).isdisjoint(pt_states) + assert not ret.cruiseState.available + assert not ret.cruiseState.enabled + assert ret.cruiseState.speed == 0 + def test_hyundai_redneck_cruise_availability(self, monkeypatch): class FakeParams: def __init__(self, *args, **kwargs):