mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-23 19:43:44 +08:00
Refactor Hyundai long tuning logic to use CP_SP flags.
Moved Hyundai-specific flag handling logic to utilize CP_SP flags instead of CP flags. This ensures better separation of parameters and aligns with the updated parameter structure. Updated related functions and class initializations for consistency.
This commit is contained in:
+1
-1
Submodule opendbc_repo updated: 68c602106f...dc56629a11
@@ -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")
|
||||
|
||||
@@ -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
|
||||
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user