diff --git a/openpilot/starpilot/aol/tests/test_ford_cancel_raw_health.py b/openpilot/starpilot/aol/tests/test_ford_cancel_raw_health.py index cc1e71cfbe..b89bc78e6a 100644 --- a/openpilot/starpilot/aol/tests/test_ford_cancel_raw_health.py +++ b/openpilot/starpilot/aol/tests/test_ford_cancel_raw_health.py @@ -159,6 +159,22 @@ def test_repeated_cancel_does_not_refresh_original_source_or_native_deadlines(): assert native.validUntilMonoTime == NOW+200_000_000 +@pytest.mark.parametrize('event_matches, expired', [(True, False), (False, False), (True, True)]) +def test_cancel_echo_uses_the_original_event_and_native_deadline(event_matches, expired): + cp, cs, feedback, sm, native, now = fixture() + assert not invoke(cp, cs, feedback, sm, now) + stamp = native.observedMonoTime + (201 if expired else 106) * 1_000_000 + next_sample = sample(cp, stamp, 3, native, combined=False) + event_ns = sm.logMonoTime['onroadEvents'] + next_sample.messages['onroadEvents'] = sm.messages['onroadEvents'] + next_sample.logMonoTime['onroadEvents'] = event_ns + if event_matches: + change(next_sample, 'aolAxisState', lambda axis: setattr(axis, 'faultEventMonoTime', event_ns)) + assert invoke(cp, cs, feedback, next_sample, stamp + 1_000_000) == (not event_matches or expired) + assert next_sample.logMonoTime['onroadEvents'] == event_ns + assert native.validUntilMonoTime == NOW + 200_000_000 + + def test_fresh_native_receipts_allow_repeated_cancel_and_new_full_engagement(): cp, cs, f, sm, native, now = fixture() assert not invoke(cp, cs, f, sm, now) diff --git a/openpilot/starpilot/aol/transport_pause.py b/openpilot/starpilot/aol/transport_pause.py index b1f2418a98..d70d763ad5 100644 --- a/openpilot/starpilot/aol/transport_pause.py +++ b/openpilot/starpilot/aol/transport_pause.py @@ -273,7 +273,8 @@ class TransportPauseFeedback: # Cancel needs acknowledged LAT, original deadlines and a fresh withdrawal event. ford_cancel_health = bool(ford_withdrawal and not cs.cruiseState.enabled and not axis.desiredLongitudinal and not axis.longitudinalActive and - 0 < event_ns <= now_ns and now_ns - event_ns <= AXIS_MAX_AGE_NS and + 0 < event_ns <= now_ns and (now_ns - event_ns <= AXIS_MAX_AGE_NS or + native is not None and native.observedMonoTime < event_ns == axis.faultEventMonoTime <= axis.observedMonoTime) and any(event.userDisable and event.name in (log.OnroadEvent.EventName.buttonCancel, log.OnroadEvent.EventName.pcmDisable) for event in sm['onroadEvents']) and 0 < int(sm.logMonoTime['pandaStates']) <= now_ns and diff --git a/prebuilt.json b/prebuilt.json index 781e7a3574..2653250fdb 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "bbe7c779fc19df3fd9767340c8b26913636b33a687074e33f3f4a8cde4071627", "schema_version": 1} +{"protected_inventory_sha256": "016119aa7d76dbfa133750b4e89537de8eee348a61e9a45fd08a091c87c9260c", "schema_version": 1}