mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-08 05:23:41 +08:00
a82935f326
Integrate onroad views, configurable widgets, local settings, steering-profile contracts, Bluetooth and Android Auto with their device and runtime services. Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Daniel Koepping <elkoled@gmail.com> Co-authored-by: Danny <dannyirwin31@yahoo.com> Co-authored-by: DimitriChrysafis <Dimitri.chrysafis@gmail.com> Co-authored-by: Dom <168790843+firestar5683@users.noreply.github.com> Co-authored-by: Harald Schäfer <harald.the.engineer@gmail.com> Co-authored-by: Prabhaav Pillai <prabhaav@msu.edu> Co-authored-by: Shane Smiskol <shane@smiskol.com> Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com> Co-authored-by: firestarsdog <229254897+firestarsdog@users.noreply.github.com> Co-authored-by: stef <19478336+stefpi@users.noreply.github.com> Co-authored-by: whoisdomi <dcantu83@gmail.com> Co-authored-by: Intelli <contact@intelli.software> Co-authored-by: pharmacomaniac <blittle65@gmail.com> Co-authored-by: prabhaavp <prabhaav@msu.edu>
45 lines
2.7 KiB
Python
45 lines
2.7 KiB
Python
"""GM distance Traffic assignments and stock Ioniq Switchback stay independent."""
|
|
from types import SimpleNamespace as NS
|
|
from pathlib import Path
|
|
from openpilot.common.params import Params
|
|
from opendbc.car.gm.tests.test_bolt_pedal import params as gm_params
|
|
from opendbc.car.gm.values import CAR as GM
|
|
from opendbc.car.hyundai.interface import CarInterface
|
|
from opendbc.car.hyundai.values import CAR, HyundaiFlags
|
|
from openpilot.starpilot.ui.feature_settings_owner import FeatureSettingsOwner
|
|
from openpilot.starpilot.ui.feature_settings_state import FeatureSettingsRequest
|
|
from openpilot.starpilot.conditional_mode.button_actions import BUTTON_PREFIX
|
|
|
|
|
|
def test_gm_distance_and_stock_ioniq_switchback_are_separate_source_bound_requests(tmp_path):
|
|
params = Params(str(tmp_path))
|
|
current = NS(cp=gm_params(GM.CHEVROLET_BOLT_ACC_2022_2023_PEDAL, setting=True, pedal=True))
|
|
owner = FeatureSettingsOwner(params, lambda group: group in ('conditional_wheel', 'switchback_wheel', 'preferences'),
|
|
vehicle_fingerprint=lambda: current.cp.carFingerprint,
|
|
vehicle_params=lambda: current.cp)
|
|
def request(row, choice):
|
|
return FeatureSettingsRequest(row.key, row.source, choice, vehicle_fingerprint=row.vehicle_fingerprint,
|
|
capability=row.capability, dependencies=row.dependencies)
|
|
rows = owner.conditional.wheel_rows()
|
|
distance = next(row for row in rows if row.key == BUTTON_PREFIX+'DistanceButtonControl')
|
|
assert distance.choices == ('Off', 'Toggle traffic mode') and distance.available
|
|
captured_gm = request(distance, 'Toggle traffic mode')
|
|
assert owner.apply(captured_gm)
|
|
cp = CarInterface.get_non_essential_params(CAR.HYUNDAI_IONIQ_6)
|
|
cp.flags = int(cp.flags | HyundaiFlags.CANFD_LKA_STEER_MSG)
|
|
cp.openpilotLongitudinalControl = False
|
|
current.cp = cp
|
|
assert not owner.apply(captured_gm)
|
|
rows = owner.conditional.wheel_rows()
|
|
assert not any(row.key == BUTTON_PREFIX+'DistanceButtonControl' for row in rows)
|
|
mode = next(row for row in rows if row.key == BUTTON_PREFIX+'ModeButtonControl')
|
|
assert mode.choices == ('Off', 'Switchback Mode') and mode.available
|
|
assert owner.apply(request(mode, 'Switchback Mode'))
|
|
assert Path(params.get_param_path('ModeButtonControl')).read_bytes() == b'7'
|
|
assert Path(params.get_param_path('DistanceButtonControl')).read_bytes() == b'6'
|
|
other = next(row for row in owner.conditional.wheel_rows() if row.key == BUTTON_PREFIX+'LongModeButtonControl')
|
|
captured_media = request(other, 'Switchback Mode')
|
|
cp.flags = int(cp.flags & ~HyundaiFlags.CANFD_LKA_STEER_MSG)
|
|
assert not owner.apply(captured_media)
|
|
assert not Path(params.get_param_path('LongModeButtonControl')).exists()
|