diff --git a/opendbc_repo/opendbc/car/toyota/ars510_preferences.py b/opendbc_repo/opendbc/car/toyota/ars510_preferences.py index 55e72c0943..8eacd9be61 100644 --- a/opendbc_repo/opendbc/car/toyota/ars510_preferences.py +++ b/opendbc_repo/opendbc/car/toyota/ars510_preferences.py @@ -20,9 +20,8 @@ def configure_radar(cp): if not supported(cp): return False cp.flags &= ~int(ToyotaFlags.ARS510_RADAR | ToyotaFlags.ARS510_FUSED) - if cp.flags & ToyotaFlags.DISABLE_RADAR: - cp.radarUnavailable = True - return False + # Alpha long's UDS disable (DISABLE_RADAR) only stops the radar's car-bus (bus 0) output; + # the ACC target on the radar bus (bus 1) keeps running at full rate, so it stays the lead source. cp.flags |= int(ToyotaFlags.ARS510_RADAR) cp.radarUnavailable = False return True diff --git a/opendbc_repo/opendbc/car/toyota/tests/test_ars510.py b/opendbc_repo/opendbc/car/toyota/tests/test_ars510.py index 3659ec8ec0..f98abdcee3 100644 --- a/opendbc_repo/opendbc/car/toyota/tests/test_ars510.py +++ b/opendbc_repo/opendbc/car/toyota/tests/test_ars510.py @@ -19,14 +19,13 @@ def test_factory_selects_only_live_supported_continental_radar(candidate, alpha_ if can_filter: fingerprint[0][0x2AA] = 8 cp = CarInterface.get_params(candidate, fingerprint, [], alpha_long, False, False) - if candidate in ARS510_RADAR_CAR and not cp.flags & ToyotaFlags.DISABLE_RADAR: + if candidate in ARS510_RADAR_CAR: + # with or without alpha long's radar disable: the disable leaves the radar bus running assert cp.flags & ToyotaFlags.ARS510_RADAR, 'AUTOMATIC_CONTINENTAL_RADAR' assert not cp.flags & ToyotaFlags.ARS510_FUSED and not cp.radarUnavailable assert isinstance(RadarInterface(cp).ars510, AccRadarInterface) else: assert not cp.flags & (ToyotaFlags.ARS510_RADAR | ToyotaFlags.ARS510_FUSED) - if candidate in ARS510_RADAR_CAR: - assert cp.radarUnavailable and RadarInterface(cp).ars510 is None def set_bits(data, start, length, value): diff --git a/openpilot/starpilot/aol/tests/test_toyota.py b/openpilot/starpilot/aol/tests/test_toyota.py index eb8c46ccbe..94ed697f61 100644 --- a/openpilot/starpilot/aol/tests/test_toyota.py +++ b/openpilot/starpilot/aol/tests/test_toyota.py @@ -140,7 +140,7 @@ class TestHighlanderAol(unittest.TestCase): with self.subTest(car=car, alpha=alpha): cp = CarInterface.get_params(car, gen_empty_fingerprint(), [], alpha, False, False) cp.flags |= int(ToyotaFlags.ARS510_RADAR) - expected = car == CAR.TOYOTA_RAV4_TSS2_2022 and not alpha + expected = car == CAR.TOYOTA_RAV4_TSS2_2022 # the ACC target receiver also runs under the radar disable self.assertEqual(qualified(cp), expected) cp.alternativeExperience = 32 self.assertEqual(qualified(cp, marked_only=True), expected) diff --git a/openpilot/starpilot/car/toyota/aol.py b/openpilot/starpilot/car/toyota/aol.py index 8e68f1169e..a438330f68 100644 --- a/openpilot/starpilot/car/toyota/aol.py +++ b/openpilot/starpilot/car/toyota/aol.py @@ -177,7 +177,8 @@ def qualified(cp, *, marked_only=False): if hold: return False allowed_flags = required_flags | ToyotaFlags.HYBRID | ToyotaFlags.HAS_BSM - if cp.carFingerprint == CAR.TOYOTA_RAV4_TSS2_2022 and not cp.openpilotLongitudinalControl: + if cp.carFingerprint == CAR.TOYOTA_RAV4_TSS2_2022: + # the ACC target receiver also runs under alpha long's radar disable (DISABLE_RADAR) allowed_flags |= ToyotaFlags.ARS510_RADAR if cp.flags & required_flags != required_flags or int(cp.flags) & ~int(allowed_flags | ToyotaFlags.AUTO_BRAKE_HOLD): return False diff --git a/openpilot/starpilot/car/toyota/tests/test_radar_preferences.py b/openpilot/starpilot/car/toyota/tests/test_radar_preferences.py index dcac6e1eac..e31e0cdc32 100644 --- a/openpilot/starpilot/car/toyota/tests/test_radar_preferences.py +++ b/openpilot/starpilot/car/toyota/tests/test_radar_preferences.py @@ -93,14 +93,17 @@ def test_automatic_factory_card_and_radard_parse_live_target(candidate): @pytest.mark.parametrize('candidate', [CAR.TOYOTA_RAV4_TSS2_2022, CAR.TOYOTA_RAV4_TSS2_2023]) -def test_disabled_radar_withdraws_a_previous_receiver_without_changing_authority(candidate): +def test_disabled_radar_keeps_acc_target_receiver_without_changing_authority(candidate): + # alpha long's UDS disable stops the radar's car-bus output only; the radar bus keeps sending the ACC target from opendbc.car.toyota.ars510_preferences import configure_radar - cp = CarInterface.get_params(candidate, gen_empty_fingerprint(), [], False, False, False) - cp.flags |= int(ToyotaFlags.DISABLE_RADAR | ToyotaFlags.ARS510_FUSED) + cp = CarInterface.get_params(candidate, gen_empty_fingerprint(), [], True, False, False) + assert cp.flags & ToyotaFlags.DISABLE_RADAR + cp.flags |= int(ToyotaFlags.ARS510_FUSED) before = cp.to_dict() - assert not configure_radar(cp) + assert configure_radar(cp) expected = before.copy() - expected['flags'] &= ~int(ToyotaFlags.ARS510_RADAR | ToyotaFlags.ARS510_FUSED) - expected['radarUnavailable'] = True + expected['flags'] = (expected['flags'] & ~int(ToyotaFlags.ARS510_FUSED)) | int(ToyotaFlags.ARS510_RADAR) + expected['radarUnavailable'] = False assert cp.to_dict() == expected - assert RadarInterface(cp).ars510 is None + assert cp.flags & ToyotaFlags.DISABLE_RADAR and cp.openpilotLongitudinalControl + assert RadarInterface(cp).ars510 is not None