From 2cca20624c09d9dfc5645560b11c95605e31b91d Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Fri, 30 Oct 2026 02:12:43 -0500 Subject: [PATCH] Finalize the admitted Sportage long AOL startup profile --- .../opendbc/car/hyundai/generic_hda2_startup.py | 11 ++++++++--- .../tests/test_generic_hda2_startup_lifecycle.py | 5 +++++ prebuilt.json | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/opendbc_repo/opendbc/car/hyundai/generic_hda2_startup.py b/opendbc_repo/opendbc/car/hyundai/generic_hda2_startup.py index 71f8c9554a..73e55b7a15 100644 --- a/opendbc_repo/opendbc/car/hyundai/generic_hda2_startup.py +++ b/opendbc_repo/opendbc/car/hyundai/generic_hda2_startup.py @@ -2,7 +2,7 @@ from copy import deepcopy from typing import Any import time -from opendbc.car.hyundai.canfd_stock_aol import qualified as stock_qualified +from opendbc.car.hyundai.canfd_stock_aol import qualified as stock_qualified, qualified_long from opendbc.car.hyundai.ecu_continuity import ContinuousECUStartup, StartupKeeper from opendbc.car.hyundai.ecu_startup import Outcome, stock_copy from opendbc.car.hyundai.radar_hda2_startup import RadarHDA2Startup @@ -91,14 +91,19 @@ class GenericHDA2Startup(RadarHDA2Startup): raise RuntimeError('Ordinary HDA-II finalization requires configured startup') if self.prepared_for(ci.CP): return - if self.outcome not in (Outcome.STOCK_UNTOUCHED, Outcome.STOCK_RESTORED) or not stock_qualified(ci.CP, marked_only=True): + long_aol = self.outcome is Outcome.SENT_UNCONFIRMED and qualified_long(ci.CP, marked_only=True) + if not long_aol and (self.outcome not in (Outcome.STOCK_UNTOUCHED, Outcome.STOCK_RESTORED) or + not stock_qualified(ci.CP, marked_only=True)): raise RuntimeError('Ordinary HDA-II startup does not admit this AOL configuration') expected: Any = deepcopy(self.prepared_cp) configs = expected.get('safetyConfigs', []) + allowed_words = tuple(word | 4 for word in STOCK_WORDS) if long_aol else STOCK_WORDS if (len(configs) != 1 or configs[0]['safetyModel'] != 'hyundaiCanfd' or - configs[0]['safetyParam'] not in STOCK_WORDS or expected['alternativeExperience'] != 0): + configs[0]['safetyParam'] not in allowed_words or expected['alternativeExperience'] != 0): raise RuntimeError('Ordinary HDA-II prepared stock profile cannot be finalized') configs[0]['safetyParam'] |= 0x800 + if long_aol: + expected['alternativeExperience'] = 32 if ci.CP.to_dict() != expected: raise RuntimeError('Ordinary HDA-II finalization changed unrelated CarParams') self.prepared_cp = expected diff --git a/opendbc_repo/opendbc/car/hyundai/tests/test_generic_hda2_startup_lifecycle.py b/opendbc_repo/opendbc/car/hyundai/tests/test_generic_hda2_startup_lifecycle.py index 893ec27021..41ceb5d3c5 100644 --- a/opendbc_repo/opendbc/car/hyundai/tests/test_generic_hda2_startup_lifecycle.py +++ b/opendbc_repo/opendbc/car/hyundai/tests/test_generic_hda2_startup_lifecycle.py @@ -183,6 +183,9 @@ def actual_card_lifecycle(identity, hybrid, alternate, gear, mode, aol): assert {key: saved.get(key) for key in keys} == settings and not saved.get_bool("ControlsReady") if mode == "rejected" and aol: expected.safetyConfigs[0].safetyParam |= 0x800 + elif mode == "sent" and aol and identity == CAR.KIA_SPORTAGE_5TH_GEN: + expected.safetyConfigs[0].safetyParam |= 0x800 + expected.alternativeExperience = 32 assert card.CP.to_dict() == expected.to_dict() if mode == "rejected": assert owner.restored and owner.outcome is Outcome.STOCK_RESTORED and owner.keeper is None @@ -270,6 +273,8 @@ def actual_card_lifecycle(identity, hybrid, alternate, gear, mode, aol): CALLER_CASES = tuple((identity, hybrid, alternate, 0x130) for identity, hybrid in FUEL_CASES for alternate in (False, True)) GEAR_SOURCE_FAMILIES = ( + (CAR.KIA_SPORTAGE_5TH_GEN, False), + (CAR.KIA_SPORTAGE_5TH_GEN, True), (CAR.HYUNDAI_STARIA_4TH_GEN, False), (CAR.KIA_CARNIVAL_2025, False), (CAR.KIA_CARNIVAL_HEV_4TH_GEN, True), diff --git a/prebuilt.json b/prebuilt.json index 8ab62b0a10..43a9259aae 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "c2c5169d118b24927f288a11723b099c0b0bf54f3757466f414e11fcfa971f60", "schema_version": 1} +{"protected_inventory_sha256": "5280e0916346f7ae965b6c57c244669dd57cb1f671a19748e172c5a8cf9e7a2b", "schema_version": 1}