Finalize the admitted Sportage long AOL startup profile

This commit is contained in:
firestar5683
2026-10-30 02:12:43 -05:00
parent 7db42dd5d6
commit 2cca20624c
3 changed files with 14 additions and 4 deletions
@@ -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
@@ -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),
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "c2c5169d118b24927f288a11723b099c0b0bf54f3757466f414e11fcfa971f60", "schema_version": 1}
{"protected_inventory_sha256": "5280e0916346f7ae965b6c57c244669dd57cb1f671a19748e172c5a8cf9e7a2b", "schema_version": 1}