Conversation
pandad's safety setter runs off deviceState.started and reads FirmwareQueryDone, ControlsReady and CarParams. manager clears them at the onroad transition, but it reacts to the same deviceState edge as pandad with no ordering between the two, so pandad can read the previous drive's values first, find everything ready, and apply the car safety mode from stale CarParams. Issue commaai#28050 described this race and commaai#28151 fixed it in 2023 by starting the safety setter off an IsOnroad param that manager wrote only after its own clear. commaai#37999 moved pandad's onroad signal to a live deviceState subscription, which dropped that guarantee, and commaai#38205 then removed the unused param. The firmware query hid the regression: 5 to 9 s in ELM327 before the car safety mode meant nothing stale was ever acted on. A car whose VIN is cached skips the query and exposes it. Clearing the three keys on the way out leaves nothing stale to read at the next ignition, whichever process reacts first. The other CLEAR_ON_ONROAD_TRANSITION keys stay as they are: the Offroad_* alerts are written onroad to be shown offroad. Seen on a 2021 Hyundai Palisade with openpilot longitudinal: the first ignition with a cached fingerprint applied the hyundai safety mode from the first frame, before card had disabled the stock radar, so the radar's SCC messages on bus 0 tripped the relay check and it stayed latched for the drive. With this change, three further cached ignitions in one power cycle applied the safety mode 7 to 12 s in, with no fault. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Process replay diff reportReplays driving segments through this PR and compares the behavior to master. ✅ 0 changed, 66 passed, 0 errors |
|
I found this PR while investigating an issue I had in my 2020 Subaru Crosstrek on sunnypilot dev. I had an LKAS fault immediately after pressing the 'Reset Calibration' button. I was on road, in drive, and not moving at the time I pressed in. I found that Sunnypilot and Openpilot both share the relevant Timeline of my issue: In my logs, Simulated test before / after PR: BEFORE PR AFTER PR |
pandad's safety setter runs off
deviceState.startedand readsFirmwareQueryDone,ControlsReadyandCarParams. manager clears them at the onroad transition, but it reacts to the samedeviceStateedge as pandad with no ordering between the two, so pandad can read the previous drive's values first, find everything ready, and apply the car safety mode from staleCarParams.Issue #28050 described this race and #28151 fixed it in 2023 by starting the safety setter off an
IsOnroadparam that manager wrote only after its own clear. #37999 moved pandad's onroad signal to a livedeviceStatesubscription, which dropped that guarantee, and #38205 then removed the unused param. The firmware query hid the regression: 5 to 9 s in ELM327 before the car safety mode meant nothing stale was ever acted on. A car whose VIN is cached skips the query and exposes it.This adds
CLEAR_ON_OFFROAD_TRANSITIONto those three keys, so nothing stale is left for the next ignition whichever process reacts first, and a params test for it. The otherCLEAR_ON_ONROAD_TRANSITIONkeys are left alone: theOffroad_*alerts are written onroad to be shown offroad.Seen on a 2021 Hyundai Palisade (comma 3X) with openpilot longitudinal: the first ignition with a cached fingerprint applied the hyundai safety mode from the first logged frame, before card had disabled the stock radar, so the radar's SCC11/12/14 on bus 0 tripped the relay check and it stayed latched for the drive. The harness relay itself was fine, LKAS11 never left bus 2. With this change, every cached ignition since (two power cycles a day for three days) applied the safety mode 7 to 12 s after the route began, after card had written the drive's own CarParams, with no fault.
Routes: ff9dba54b42b3afa|00000043--b7fb6bc078 (the failure); ff9dba54b42b3afa|00000051--39b47d07c0 and ff9dba54b42b3afa|00000053--cfcb09886f (this change, cached ignitions, safety mode applied after card's own CarParams, no fault). Since it landed on my fork on 2026-09-03 every cached ignition has been clean; the first ignition after each update still runs the full query, as before.
Companion: commaai/opendbc PR "vin: retries query the standard VIN addresses directly", which is what put this car on the cached path.
🤖 Generated with Claude Code