mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 03:03:41 +08:00
Skip irrelevant Toyota accessory configuration checks
This commit is contained in:
@@ -57,8 +57,12 @@ def apply(cp, *, camera_twoaa=False):
|
||||
cp.alphaLongitudinalAvailable = bool(cp.flags & (ToyotaFlags.NO_DSU | ToyotaFlags.RADAR_ACC))
|
||||
|
||||
|
||||
@cached_config
|
||||
def configured(cp):
|
||||
return bool(cp is not None and cp.flags & int(ToyotaFlags.RADAR_CAN_FILTER) and _configured(cp))
|
||||
|
||||
|
||||
@cached_config
|
||||
def _configured(cp):
|
||||
from opendbc.car.toyota.pedal_composite import parent_cp
|
||||
cp = parent_cp(cp)
|
||||
from opendbc.car.toyota import camera_2aa_filter
|
||||
|
||||
@@ -89,8 +89,12 @@ def apply(cp):
|
||||
cp.dashcamOnly = False
|
||||
|
||||
|
||||
@cached_config
|
||||
def configured(cp):
|
||||
return bool(cp is not None and cp.flags & int(ToyotaFlags.DSU_BYPASS) and _configured(cp))
|
||||
|
||||
|
||||
@cached_config
|
||||
def _configured(cp):
|
||||
from opendbc.car.toyota.pedal_composite import parent_cp
|
||||
cp = parent_cp(cp)
|
||||
if (
|
||||
|
||||
@@ -64,6 +64,8 @@ def hardware_supported(candidate, fingerprint, car_fw):
|
||||
|
||||
|
||||
def configured(cp):
|
||||
if cp is None or not cp.flags & int(ToyotaFlags.GAS_INTERCEPTOR):
|
||||
return False
|
||||
from opendbc.car.toyota.pedal_composite import hold_base_cp
|
||||
cp = hold_base_cp(cp)
|
||||
from opendbc.car.toyota import pedal_composite
|
||||
|
||||
@@ -114,8 +114,12 @@ def parent_modules():
|
||||
return (dsu_bypass, prius_longitudinal, advert_filter, rav4h_filter, radar_filter)
|
||||
|
||||
|
||||
@cached_config
|
||||
def configured(cp):
|
||||
return bool(cp is not None and cp.flags & int(ToyotaFlags.GAS_INTERCEPTOR) and _configured(cp))
|
||||
|
||||
|
||||
@cached_config
|
||||
def _configured(cp):
|
||||
return marked(cp) and not cp.secOcRequired and any(module.configured(parent_cp(cp)) for module in parent_modules())
|
||||
|
||||
|
||||
|
||||
@@ -42,8 +42,12 @@ def apply(cp):
|
||||
cp.alphaLongitudinalAvailable = False
|
||||
|
||||
|
||||
@cached_config
|
||||
def configured(cp):
|
||||
return bool(cp is not None and cp.flags & int(ToyotaFlags.LONG_FILTER) and _configured(cp))
|
||||
|
||||
|
||||
@cached_config
|
||||
def _configured(cp):
|
||||
from opendbc.car.toyota.pedal_composite import parent_cp
|
||||
cp = parent_cp(cp)
|
||||
from opendbc.car.toyota import prius_retrofit_advert
|
||||
|
||||
@@ -29,8 +29,12 @@ def configured(cp):
|
||||
cp.openpilotLongitudinalControl == (cp.safetyConfigs[0].safetyParam == 0x8049))
|
||||
|
||||
|
||||
@cached_config
|
||||
def eps73_status_configured(cp):
|
||||
return bool(cp is not None and cp.flags & int(ToyotaFlags.LONG_FILTER) and _eps73_status_configured(cp))
|
||||
|
||||
|
||||
@cached_config
|
||||
def _eps73_status_configured(cp):
|
||||
from opendbc.car.toyota.pedal_composite import parent_cp
|
||||
cp = parent_cp(cp)
|
||||
return configured(cp) and cp.carFingerprint in (CAR.TOYOTA_PRIUS, CAR.TOYOTA_PRIUS_RETROFIT) and cp.safetyConfigs[0].safetyParam in (0x8049, 0x8249)
|
||||
|
||||
@@ -34,8 +34,12 @@ def hardware_supported(candidate, fingerprint, car_fw):
|
||||
return True
|
||||
|
||||
|
||||
@cached_config
|
||||
def configured(cp):
|
||||
return bool(cp is not None and cp.flags & int(ToyotaFlags.LONG_FILTER) and _configured(cp))
|
||||
|
||||
|
||||
@cached_config
|
||||
def _configured(cp):
|
||||
from opendbc.car.toyota.pedal_composite import parent_cp
|
||||
cp = parent_cp(cp)
|
||||
from opendbc.car.toyota import eps8_sdsu, legacy_sdsu
|
||||
|
||||
@@ -13,6 +13,7 @@ from openpilot.starpilot.car.toyota.tests.test_pedal_parent_configurations impor
|
||||
|
||||
|
||||
CHECKS = (dsu_bypass.configured, pedal_composite.configured, aol.qualified)
|
||||
CACHED_CHECKS = (dsu_bypass._configured, pedal_composite._configured, aol.qualified)
|
||||
|
||||
|
||||
def params():
|
||||
@@ -23,23 +24,26 @@ def params():
|
||||
return cp
|
||||
|
||||
|
||||
@pytest.mark.parametrize('check', CHECKS)
|
||||
@pytest.mark.parametrize('check,cached', zip(CHECKS, CACHED_CHECKS, strict=True))
|
||||
@pytest.mark.parametrize('field,value', [
|
||||
('brand', 'other'), ('carFingerprint', 'unknown'), ('flags', 0), ('passive', True),
|
||||
('dashcamOnly', True), ('notCar', True), ('pcmCruise', False), ('secOcRequired', True),
|
||||
('openpilotLongitudinalControl', False), ('alternativeExperience', 1), ('autoResumeSng', True),
|
||||
('alphaLongitudinalAvailable', True), ('steerControlType', 'angle'), ('carVin', 'changed'),
|
||||
])
|
||||
def test_mutable_builder_and_reader_alias(check, field, value):
|
||||
def test_mutable_builder_and_reader_alias(check, cached, field, value):
|
||||
cp = params()
|
||||
alias = cp.as_reader()
|
||||
assert check(cp)
|
||||
before = check.cache_info().misses
|
||||
before = cached.cache_info().misses
|
||||
assert getattr(cp, field) != value
|
||||
setattr(cp, field, value)
|
||||
expected = check.__wrapped__(cp)
|
||||
expected = cached.__wrapped__(cp)
|
||||
assert check(cp) == check(alias) == expected
|
||||
assert check.cache_info().misses > before
|
||||
if field == 'flags' and check is not cached:
|
||||
assert not expected and cached.cache_info().misses == before
|
||||
else:
|
||||
assert cached.cache_info().misses > before
|
||||
|
||||
|
||||
@pytest.mark.parametrize('check', CHECKS)
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "cc4f511ec71ca7100e9c3f4831582d2ae306d7ea8cbedc654ce2fc259b9b37b5", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "919e134648524a529e96f11df71aeb2d5ddffa2c20f0ed564fe7f17084d9bee8", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user