Log panda safety violations
To start, I'm thinking we add a field to pandaStates where these flags can be set. This will help debug controlsMismatches, where controls_allowed mysteriously goes low. It should at least cover:
- [ ] lag detector tripped
- [ ] RX addr checks (checksum + counter)
- [ ] TX steering violations
Having ridden this ride before, I'd like to see ALL controls_allowed transitions have an explicit reason every time and pass that reason up in pandaStates. Could do just reasons for exiting if we don't care about entering. Maybe migrate accesses in vehicle safety code to a getter/setter function or macro pattern to do it.
Something along these lines:
controls_allowed_transition(true, CD_NONE);
...
controls_allowed_transition(false, CD_BRAKE);
struct PandaState @0xa7649e2575e4591e {
...
lastControlsDisabledReason @26 :ControlsDisabledReasons;
enum ControlsDisabledReasons {
unknown @0;
brakePressed @1;
gasPressed @2;
heatbeatLost @3;
canNotValid @4;
...
}
Hasn't been as necessary for my use cases anymore. It's pretty easy to reproduce offline now.