Fix Steering Controller missing in UI for PID cars when CarParams is a reader

This commit is contained in:
fantasist
2026-11-29 21:17:11 -06:00
committed by firestar5683
parent 91e4edf3b3
commit 521e32c316
3 changed files with 15 additions and 2 deletions
@@ -110,7 +110,7 @@ def torque_choice_cp(cp):
not cp.safetyConfigs or any(config.safetyModel in unsafe for config in cp.safetyConfigs)):
return None
from opendbc.car.interfaces import CarInterfaceBase
prepared = cp.as_reader().as_builder()
prepared = cp.as_builder() if hasattr(cp, 'as_builder') else cp.as_reader().as_builder()
CarInterfaceBase.configure_torque_tune(prepared.carFingerprint, prepared.lateralTuning)
return prepared if generic_torque_supported(prepared) else None
except (AttributeError, TypeError, ValueError, OverflowError, KeyError, NotImplementedError, OSError):
@@ -78,6 +78,19 @@ def test_developer_choice_saved_and_startup_snapshot_is_frozen(tmp_path, identit
assert not owner.apply(replace(request, value='Invented Controller'))
@pytest.mark.parametrize('identity', PID_CARS)
def test_reader_car_params_exposes_steering_controller_in_settings(tmp_path, identity):
cp = factory(identity).as_reader()
assert torque_choice_cp(cp) is not None
params = Params(str(tmp_path))
owner = FeatureSettingsOwner(params, lambda _: True, vehicle_fingerprint=lambda: identity, vehicle_params=lambda: cp)
for page in ('torque', 'torque/developer'):
state = owner.snapshot(page, parked=True, system_long=False, lateral_context=True, metric=False)
current = next(r for r in state.rows if r.key == DOCUMENT_KEY)
assert current.available and current.value == 'Stock Controller'
assert current.choices == ('Stock Controller', 'Torque Controller', 'StarPilot Controller')
@pytest.mark.parametrize('field,value', [('steerControlType', 'angle'), ('steerControlType', 'curvature'),
('brand', 'toyota'), ('notCar', True), ('passive', True), ('dashcamOnly', True), ('carFingerprint', 'UNKNOWN')])
def test_forced_choice_refuses_unsupported_configuration(field, value):
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "a768fade59ca6b55109eb1980e5c158605869d9aad9f8074f8a53eeea82779a5", "schema_version": 1}
{"protected_inventory_sha256": "cc0b33df4c5668611841a226ad800d762ec35c406951b93803e36ee5504adf68", "schema_version": 1}