This part is for members
Membership opens soon. Leave your email and we'll tell you the day it does. Founding members get the launch price.
Keep watching the free partsTwo state machines 2: the application layer's table and five states
The application layer's scheduler is one table in app_scheduler.c: app_table has a row per mode with four hooks (init / start / run / stop) and a type, all PDS (only one on stage at a time); kAppInfo holds each row's enable, app_state and app_result. set_app stops any other PDS app that is not IDLE and runs init → READY; PpModeInit writes 0 to the control word. AppRun walks three blocks every position tick: READY calls start, RUNNING calls run only while hw_ready_state is 1 and otherwise drops back to READY, SUCCESS / ERROR call stop and go IDLE. Real runs: position mode is selected at 1000 ms, and in the 102 ms before calibration finishes PpModeStart is called 1026 times; RUNNING sticks at 1102.55. No mode in this version reaches SUCCESS by itself (every return SUCCESS is commented out); the only FAIL is an unsupported homing method: the setter accepts method 1, SetMethodRun does not, and in one tick at 1400.05 the app goes RUNNING → ERROR → IDLE while the motor never enables. A disable leaves PP RUNNING; the re-enable restarts the planner through PP's own edge and the move still ends at 301372. Switching to PV mid-move: PvModeInit writes 0, so the new mode runs and the motor is off.