diff --git a/openpilot/starpilot/lateral/controller_selection.py b/openpilot/starpilot/lateral/controller_selection.py index bcc761c300..669eeb71b8 100644 --- a/openpilot/starpilot/lateral/controller_selection.py +++ b/openpilot/starpilot/lateral/controller_selection.py @@ -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): diff --git a/openpilot/starpilot/lateral/tests/test_controller_types.py b/openpilot/starpilot/lateral/tests/test_controller_types.py index 540915b9b8..1348b015ec 100644 --- a/openpilot/starpilot/lateral/tests/test_controller_types.py +++ b/openpilot/starpilot/lateral/tests/test_controller_types.py @@ -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): diff --git a/prebuilt.json b/prebuilt.json index 28e4baeb08..06d464b560 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "a768fade59ca6b55109eb1980e5c158605869d9aad9f8074f8a53eeea82779a5", "schema_version": 1} +{"protected_inventory_sha256": "cc0b33df4c5668611841a226ad800d762ec35c406951b93803e36ee5504adf68", "schema_version": 1}