From 76bcea3e723dbccc6d49c281a07e057d00b68b44 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Fri, 17 Apr 2026 01:42:13 -0500 Subject: [PATCH] HKG Test --- opendbc_repo/opendbc/car/hyundai/carstate.py | 16 +++++++++++++++- opendbc_repo/opendbc/car/hyundai/interface.py | 4 ++++ opendbc_repo/opendbc/car/hyundai/values.py | 6 +++++- opendbc_repo/opendbc/car/interfaces.py | 5 ++++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/opendbc_repo/opendbc/car/hyundai/carstate.py b/opendbc_repo/opendbc/car/hyundai/carstate.py index 7c4f3a96a..2bff9b3b1 100644 --- a/opendbc_repo/opendbc/car/hyundai/carstate.py +++ b/opendbc_repo/opendbc/car/hyundai/carstate.py @@ -7,7 +7,7 @@ from opendbc.can import CANDefine, CANParser from opendbc.car import Bus, create_button_events, structs from opendbc.car.common.conversions import Conversions as CV from opendbc.car.hyundai.hyundaicanfd import CanBus -from opendbc.car.hyundai.values import HyundaiFlags, CAR, DBC, Buttons, CarControllerParams +from opendbc.car.hyundai.values import HyundaiFlags, HyundaiStarPilotFlags, CAR, DBC, Buttons, CarControllerParams from opendbc.car.interfaces import CarStateBase ButtonType = structs.CarState.ButtonEvent.Type @@ -22,6 +22,18 @@ BUTTONS_DICT = {Buttons.RES_ACCEL: ButtonType.accelCruise, Buttons.SET_DECEL: Bu Buttons.GAP_DIST: ButtonType.gapAdjustCruise, Buttons.CANCEL: ButtonType.cancel} +def calculate_canfd_speed_limit(CP, FPCP, cp, cp_cam, speed_factor): + if not (FPCP.flags & HyundaiStarPilotFlags.SPEED_LIMIT_AVAILABLE): + return 0.0 + + speed_limit_bus = cp if CP.flags & HyundaiFlags.CANFD_LKA_STEERING else cp_cam + try: + speed_limit = speed_limit_bus.vl["FR_CMR_02_100ms"]["ISLW_SpdCluMainDis"] + return speed_limit * speed_factor if 1 <= speed_limit <= 252 else 0.0 + except (KeyError, ValueError): + return 0.0 + + class CarState(CarStateBase): def __init__(self, CP, FPCP): super().__init__(CP, FPCP) @@ -269,6 +281,7 @@ class CarState(CarStateBase): ret.cruiseState.standstill = False else: cp_cruise_info = cp_cam if self.CP.flags & HyundaiFlags.CANFD_CAMERA_SCC else cp + ret.cruiseState.available = cp_cruise_info.vl["SCC_CONTROL"]["MainMode_ACC"] == 1 ret.cruiseState.enabled = cp_cruise_info.vl["SCC_CONTROL"]["ACCMode"] in (1, 2) ret.cruiseState.standstill = cp_cruise_info.vl["SCC_CONTROL"]["CRUISE_STANDSTILL"] == 1 ret.cruiseState.speed = cp_cruise_info.vl["SCC_CONTROL"]["VSetDis"] * speed_factor @@ -301,6 +314,7 @@ class CarState(CarStateBase): ret.blockPcmEnable = not self.recent_button_interaction() fp_ret = custom.StarPilotCarState.new_message() + fp_ret.dashboardSpeedLimit = calculate_canfd_speed_limit(self.CP, self.FPCP, cp, cp_cam, speed_factor) return ret, fp_ret diff --git a/opendbc_repo/opendbc/car/hyundai/interface.py b/opendbc_repo/opendbc/car/hyundai/interface.py index ea34cc3f3..63e95ded7 100644 --- a/opendbc_repo/opendbc/car/hyundai/interface.py +++ b/opendbc_repo/opendbc/car/hyundai/interface.py @@ -59,6 +59,10 @@ class CarInterface(CarInterfaceBase): if not ret.flags & HyundaiFlags.RADAR_SCC: ret.flags |= HyundaiFlags.CANFD_CAMERA_SCC.value + # Ioniq 6 HDA2 uses the camera SCC path for stock ACC, even on LKA steering variants. + if candidate == CAR.HYUNDAI_IONIQ_6: + ret.flags |= HyundaiFlags.CANFD_CAMERA_SCC.value + # Some LKA steering cars have alternative messages for gear checks # ICE cars do not have 0x130; GEARS message on 0x40 or 0x70 instead if 0x130 not in fingerprint[CAN.ECAN]: diff --git a/opendbc_repo/opendbc/car/hyundai/values.py b/opendbc_repo/opendbc/car/hyundai/values.py index d5ffc4705..dab54b2b1 100644 --- a/opendbc_repo/opendbc/car/hyundai/values.py +++ b/opendbc_repo/opendbc/car/hyundai/values.py @@ -73,6 +73,10 @@ class HyundaiStarPilotSafetyFlags(IntFlag): AOL_LKAS_ON_ENGAGE = 2048 +class HyundaiStarPilotFlags(IntFlag): + SPEED_LIMIT_AVAILABLE = 1 + + class HyundaiFlags(IntFlag): # Dynamic Flags @@ -350,7 +354,7 @@ class CAR(Platforms): HYUNDAI_IONIQ_6 = HyundaiCanFDPlatformConfig( [HyundaiCarDocs("Hyundai Ioniq 6 (with HDA II) 2023-24", "Highway Driving Assist II", car_parts=CarParts.common([CarHarness.hyundai_p]))], HYUNDAI_IONIQ_5.specs, - flags=HyundaiFlags.EV | HyundaiFlags.CANFD_NO_RADAR_DISABLE, + flags=HyundaiFlags.EV, ) HYUNDAI_TUCSON_4TH_GEN = HyundaiCanFDPlatformConfig( [ diff --git a/opendbc_repo/opendbc/car/interfaces.py b/opendbc_repo/opendbc/car/interfaces.py index 75a818eec..73f24189d 100644 --- a/opendbc_repo/opendbc/car/interfaces.py +++ b/opendbc_repo/opendbc/car/interfaces.py @@ -20,7 +20,7 @@ from opendbc.car.common.simple_kalman import KF1D, get_kalman_gain from opendbc.car.gm.values import CAR as GM from opendbc.car.honda.values import CAR as HONDA, HONDA_BOSCH, HONDA_CAMERA_MESSAGE_CARS, HondaSafetyFlags, HondaStarPilotFlags from opendbc.car.hyundai.hyundaicanfd import CanBus -from opendbc.car.hyundai.values import CAR as HYUNDAI, CANFD_CAR, HyundaiFlags, HyundaiStarPilotSafetyFlags +from opendbc.car.hyundai.values import CAR as HYUNDAI, CANFD_CAR, HyundaiFlags, HyundaiStarPilotFlags, HyundaiStarPilotSafetyFlags from opendbc.car.mock.values import CAR as MOCK from opendbc.car.toyota.values import CAR as TOYOTA, NO_DSU_CAR, TSS2_CAR, UNSUPPORTED_DSU_CAR, ToyotaStarPilotFlags, ToyotaSafetyFlags from opendbc.car.values import PLATFORMS @@ -214,8 +214,11 @@ class CarInterfaceBase(ABC): elif platform in HYUNDAI: if candidate in CANFD_CAR: hda2 = Ecu.adas in [fw.ecu for fw in car_fw] + CAN = CanBus(None, fingerprint, bool(CP.flags & HyundaiFlags.CANFD_LKA_STEERING)) fp_ret.isHDA2 = hda2 + if 0x1FA in fingerprint[CAN.ECAN]: + fp_ret.flags |= HyundaiStarPilotFlags.SPEED_LIMIT_AVAILABLE.value if CP.flags & HyundaiFlags.HAS_LDA_BUTTON: fp_ret.safetyConfigs[-1].safetyParam |= HyundaiStarPilotSafetyFlags.HAS_LDA_BUTTON.value