mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-10-29 09:33:48 +08:00
Accept forwarded Toyota radar-filter advertisements
This commit is contained in:
@@ -24,7 +24,7 @@ def hardware_supported(candidate, fingerprint):
|
||||
all(bus in (0, 2) and messages[0x2FF] == 4 for bus, messages in fingerprint.items() if 0x2FF in messages)):
|
||||
return True
|
||||
return (candidate in PROFILES and fingerprint.get(0, {}).get(0x2AA) == 8 and
|
||||
not any(0x2AA in frames for bus, frames in fingerprint.items() if bus != 0) and
|
||||
all(bus in (0, 2) and frames[0x2AA] == 8 for bus, frames in fingerprint.items() if 0x2AA in frames) and
|
||||
not any(addr in frames for frames in fingerprint.values() for addr in (0x201, 0x2FF)))
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import pytest
|
||||
from opendbc.car import gen_empty_fingerprint
|
||||
from opendbc.car.toyota import radar_filter
|
||||
from opendbc.car.toyota.interface import CarInterface
|
||||
from openpilot.starpilot.car.toyota.tests.test_pedal_caller_native import firmware
|
||||
|
||||
|
||||
@pytest.mark.parametrize('candidate', sorted(radar_filter.PROFILES))
|
||||
@pytest.mark.parametrize('alpha', [False, True])
|
||||
def test_same_length_advertisement_copy_preserves_factory(candidate, alpha):
|
||||
fp = gen_empty_fingerprint()
|
||||
fp[0][0x2AA] = 8
|
||||
fw = firmware(candidate)
|
||||
before = CarInterface.get_params(candidate, fp, fw, alpha, False, False)
|
||||
fp[2][0x2AA] = 8
|
||||
after = CarInterface.get_params(candidate, fp, fw, alpha, False, False)
|
||||
assert radar_filter.hardware_supported(candidate, fp)
|
||||
assert radar_filter.configured(after)
|
||||
assert after.to_dict() == before.to_dict()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('candidate', sorted(radar_filter.PROFILES))
|
||||
@pytest.mark.parametrize('bad', ['only_copy', 'source7', 'copy4', 'copy7', 'bus1', 'echo', 'pedal', 'mixed'])
|
||||
def test_unsupported_advertisement_copies_do_not_enroll(candidate, bad):
|
||||
fp = gen_empty_fingerprint()
|
||||
fp[0][0x2AA] = fp[2][0x2AA] = 8
|
||||
if bad == 'only_copy':
|
||||
del fp[0][0x2AA]
|
||||
elif bad == 'source7':
|
||||
fp[0][0x2AA] = 7
|
||||
elif bad.startswith('copy'):
|
||||
fp[2][0x2AA] = int(bad[-1])
|
||||
elif bad in ('bus1', 'echo'):
|
||||
fp[1 if bad == 'bus1' else 128] = {0x2AA: 8}
|
||||
else:
|
||||
fp[0][0x201 if bad == 'pedal' else 0x2FF] = 6 if bad == 'pedal' else 4
|
||||
assert not radar_filter.hardware_supported(candidate, fp)
|
||||
@@ -0,0 +1,15 @@
|
||||
import pytest
|
||||
from opendbc.car.toyota import radar_filter
|
||||
from openpilot.starpilot.car.toyota.tests import test_rav4_angle_filter_callers as helpers
|
||||
from openpilot.starpilot.car.toyota.tests.test_toyota_cpp_transport import host_heartbeat_bridge as host_heartbeat_bridge
|
||||
|
||||
source_matched_native = helpers.source_matched_native
|
||||
daemon_gc_scope = helpers.daemon_gc_scope
|
||||
|
||||
|
||||
@pytest.mark.parametrize('candidate', sorted(radar_filter.PROFILES))
|
||||
@pytest.mark.parametrize('alpha,disable', [(False, False), (True, False), (True, True)])
|
||||
@pytest.mark.parametrize('aol', [False, True])
|
||||
def test_forwarded_advertisement_actual_callers(candidate, alpha, disable, aol, tmp_path, host_heartbeat_bridge):
|
||||
advertisements = [(0x2AA, bytes(8), bus) for bus in (0, 2)]
|
||||
helpers.run_case(candidate, alpha, disable, 0, tmp_path, aol=aol, bridge=host_heartbeat_bridge, filter_advertisements=advertisements)
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "121cacc5db8d25f990e3f775629195b60e0627b19f9b2c8aa48f68d6db578832", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "1b232d611440fc932c2a7cc7abb80e2f32fa1dad49f470afbf2121771de57960", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user