State Machine
The system always exists in one of the predefined states, also known as modes.
You can read the current mode in the /app_mode variable at the root level. The mode is also broadcast in both CAN status messages — see CAN Messages. The mode is complemented by the global application flags — see Status Word.
The values are ordered by activity: a higher value means the system is further along toward full generation. This makes range checks meaningful — for example app_mode >= 95 means "the engine is running", app_mode >= 85 means "the starting sequence is engaged or beyond".
Any state falls back to STOPPED when the start request is released, to ERROR on a controller fault, and to OVERVOLTAGE if the engine overspeeds while running. OVERVOLTAGE and MAX_TRIALS are latched — the latch survives even a transient controller error, and only releasing the start request resets it. The overvoltage latch additionally propagates to both controllers of a pair: a hazard of the shared shaft and DC bus stops the whole system.
In a multi-master system the following controller mirrors the mode of the leader during the starting sequence, and it does not report MODE_OVR while the leader drives its motor — that is the normal operating condition.
When a DC regulation limiter hovers around exactly zero demand (typically the voltage limiter on a nearly full battery), the mode may alternate between MODE_RAMPUP and MODE_RAMPDOWN at the limiter's own pace, with a status broadcast on each change. This is bounded and harmless, and will be smoothed in a future release.