IQ.Pilot Release Commit @ 658635c

This commit is contained in:
IQ.Lvbs CI [bot]
2026-07-28 20:45:48 -05:00
parent 72d8a2d141
commit 03c3158b81
2 changed files with 28 additions and 2 deletions
+10 -1
View File
@@ -745,7 +745,16 @@ class SelfdriveD(GapButtonActions):
self.is_ldw_enabled = self.params.get_bool("IsLdwEnabled")
self.disengage_on_accelerator = self.params.get_bool("DisengageOnAccelerator")
self.experimental_mode = self.params.get_bool("ExperimentalMode") and self.CP.openpilotLongitudinalControl
self.personality = self.params.get("LongitudinalPersonality", return_default=True)
# Params can be changed while selfdrived is running. Keep the live value in
# the same valid enum range enforced during startup; otherwise a stale value
# (for example 3) makes the alert callback lookup raise KeyError and kills
# selfdrived.
self.personality = get_sanitize_int_param(
"LongitudinalPersonality",
min(log.LongitudinalPersonality.schema.enumerants.values()),
max(log.LongitudinalPersonality.schema.enumerants.values()),
self.params,
)
self.nav_exit_lane_change = self._read_nav_exit_lane_change()
self.model_download_pending = self.params.get("ModelManager_DownloadIndex") is not None
@@ -1,6 +1,6 @@
from cereal import car
from openpilot.selfdrive.selfdrived.selfdrived import _cleanup_startup_params
from openpilot.selfdrive.selfdrived.selfdrived import _cleanup_startup_params, get_sanitize_int_param
class DummyParams:
@@ -21,3 +21,20 @@ class TestLongitudinalPrefPersistence:
_cleanup_startup_params(cp, params)
assert params.removed == []
def test_invalid_personality_is_clamped_before_use(self):
class ParamsWithInvalidPersonality:
def __init__(self):
self.value = 3
def get(self, key: str, return_default: bool = False) -> int:
assert key == "LongitudinalPersonality"
return self.value
def put(self, key: str, value: int) -> None:
assert key == "LongitudinalPersonality"
self.value = value
params = ParamsWithInvalidPersonality()
assert get_sanitize_int_param("LongitudinalPersonality", 0, 2, params) == 2
assert params.value == 2