diff --git a/opendbc_repo b/opendbc_repo index 68c602106f..dc56629a11 160000 --- a/opendbc_repo +++ b/opendbc_repo @@ -1 +1 @@ -Subproject commit 68c602106ff8c0608059f27a9d764050a1e7ee37 +Subproject commit dc56629a11114b5f13a06a9d0a6248751394ed01 diff --git a/selfdrive/car/card.py b/selfdrive/car/card.py index d78846f639..76ac4e36d1 100755 --- a/selfdrive/car/card.py +++ b/selfdrive/car/card.py @@ -26,7 +26,6 @@ from openpilot.selfdrive.car.helpers import convert_carControlSP, convert_to_cap from openpilot.sunnypilot.mads.helpers import set_alternative_experience, set_car_specific_params from openpilot.sunnypilot.selfdrive.car import interfaces as sunnypilot_interfaces -from openpilot.sunnypilot.selfdrive.car.hkg_specific_params import set_hyundai_long_tune_flag REPLAY = "REPLAY" in os.environ @@ -110,10 +109,10 @@ class Car: self.CI = get_car(*self.can_callbacks, obd_callback(self.params), experimental_long_allowed, num_pandas, cached_params, fixed_fingerprint) sunnypilot_interfaces.setup_car_interface_sp(self.CI.CP, self.CI.CP_SP, self.params) + sunnypilot_interfaces.set_hyundai_long_tune_flag(self.CI.CP_SP, self.params) self.RI = interfaces[self.CI.CP.carFingerprint].RadarInterface(self.CI.CP, self.CI.CP_SP) self.CP = self.CI.CP self.CP_SP = self.CI.CP_SP - set_hyundai_long_tune_flag(self.CP) # continue onto next fingerprinting step in pandad self.params.put_bool("FirmwareQueryDone", True) @@ -130,7 +129,6 @@ class Car: # mads set_alternative_experience(self.CP, self.params) set_car_specific_params(self.CP, self.CP_SP, self.params) - set_hyundai_long_tune_flag(self.CP) # Dynamic Experimental Control self.dynamic_experimental_control = self.params.get_bool("DynamicExperimentalControl") diff --git a/sunnypilot/selfdrive/car/hkg_specific_params.py b/sunnypilot/selfdrive/car/hkg_specific_params.py deleted file mode 100644 index a04cc99437..0000000000 --- a/sunnypilot/selfdrive/car/hkg_specific_params.py +++ /dev/null @@ -1,18 +0,0 @@ -from opendbc.car import structs -from opendbc.sunnypilot.car.hyundai.values import HyundaiFlagsSP -from openpilot.common.params import Params - -class HyundaiLongTuneParams: - @staticmethod - def param(params, key: str) -> bool: - val = params.get(key) - if isinstance(val, bytes): - val = val.decode("utf-8") - return val in ["1", "2"] - -def set_hyundai_long_tune_flag(CP: structs.CarParams): - params = Params() - if HyundaiLongTuneParams.param(params, "HyundaiLongTune"): - CP.flags |= HyundaiFlagsSP.HKGLONGTUNING.value - if params.get_bool("HyundaiSmootherBraking"): - CP.flags |= HyundaiFlagsSP.HKGLONGTUNING_BRAKING.value diff --git a/sunnypilot/selfdrive/car/interfaces.py b/sunnypilot/selfdrive/car/interfaces.py index 375ce7fa7f..9975142757 100644 --- a/sunnypilot/selfdrive/car/interfaces.py +++ b/sunnypilot/selfdrive/car/interfaces.py @@ -33,6 +33,20 @@ def setup_car_interface_sp(CP: structs.CarParams, CP_SP: structs.CarParamsSP, pa CP.radarUnavailable = False +def set_hyundai_long_tune_flag(CP_SP: structs.CarParamsSP, params): + val = params.get("HyundaiLongTune") + if isinstance(val, bytes): + val = val.decode("utf-8") + if isinstance(val, str) and ',' in val: + val_list = [v.strip() for v in val.split(',')] + else: + val_list = [val] + + if any(item in ["1", "2"] for item in val_list): + CP_SP.flags |= HyundaiFlagsSP.HKGLONGTUNING.value + if params.get_bool("HyundaiSmootherBraking"): + CP_SP.flags |= HyundaiFlagsSP.HKGLONGTUNING_BRAKING.value + def initialize_car_interface_sp(CP: structs.CarParams, CP_SP: structs.CarParamsSP, params, can_recv: CanRecvCallable, can_send: CanSendCallable): if CP.brand == 'hyundai':