elantra hybrid

This commit is contained in:
firestar5683
2026-05-21 10:00:09 -05:00
parent 58e7f84627
commit 55f110351e
2 changed files with 29 additions and 7 deletions
+7 -7
View File
@@ -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
@@ -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):