Repository navigation
Conversation
This was referenced Dec 5, 2026
tests/task-planner brings task into each situation its planner tells apart (E-stop, off, Manual, MDI idle and running, Auto idle, reading, waiting and paused) and sends it every command emcTaskPlan() handles, one at a time, plus one it has no case for. From task's own debug output it records, for each, whether the planner issued the command, queued it for later, refused it or handled it itself, and what situation the command left task in. The table is compared with tests/task-planner/ expected, which is the behaviour of today's planner. A change to the planner that is not meant to change behaviour leaves the table as it is; one that is shows up as a diff of it. The commands come from test_task_probe, a small NML client that sends any of them with arguments that change as little as possible. It is built for run-in-place only and not installed; the test skips without it.
emcTaskPlan() found its command itself: it compared emcCommand's serial number with the echoed one to tell a new command from none, and allow_while_idle_type() read the command's type from the NML buffer once more. Have the main loop make that decision and pass the new command, or NULL, and use only that inside the planner. This is what lets a command reach the planner by another way than the NML buffer. No change in behaviour: tests/task-planner is unchanged.
The planner's tables repeated the commands each passes straight to emcTaskIssueCommand(): 22 accepted in any state, three more only while the machine is off, twelve once it is on, the spindle commands unless a program is reading or waiting, the program and I/O commands unless one runs, and so on. isImmediate() now says this once, by the state, mode and interpreter state task is in, and each table keeps only what is special to it and its own refusal. allow_while_idle_type() is part of it now, and the three tool commands share queueToolCommand(). No change in behaviour: tests/task-planner is unchanged, and fails if spindle orient is let through in Manual, as an example of a slip.
EMC_JOG_ABS, EMC_JOINT_HALT, EMC_JOINT_SET_FERROR, EMC_JOINT_SET_MIN_FERROR, EMC_JOINT_SET_HOMING_PARAMS, EMC_TRAJ_SET_VELOCITY and EMC_TRAJ_SET_ACCELERATION, with their classes, task's handling of them and their rows in the planner table. emcJogAbs() had no other caller.
… of checkInterpList() checkInterpList() lost its limit checks long ago and always returned 0; it now only shows the operator errors of the lines it drops. task read [TASK]MDI_QUEUED_COMMANDS and never used it.
42 file-level pointers each held the cast for one case. Those used once are folded into the call; the others are declared in their case.
emcTaskCheckPreconditions() and emcTaskCheckPostconditions() become commandWaits(), and the STEPPING_CHECK macro becomes steppingHolds(). The table says what the two switches said, command for command.
emcTaskPlan() works out the situation once, then a command is handled by the planner itself (planSpecial()), passed straight through (isImmediate()) or refused (refuse()). The planner table is unchanged.
With EMC_JOG_ABS and emcJogAbs() gone the handler had no caller. In teleop it was not absolute either: axis_jog_abs() added the target to the current position.
tests/task-planner and test_task_probe recorded what the planner did with every command, to show that the refactoring of emcTaskPlan() changed nothing. That work is done.
rene-dev
force-pushed
the
task-planner-refactor
branch
from
December 6, 2026 12:52
3e31a6d to
2b89446
Compare
BsAtHome
reviewed
Dec 6, 2026
From the review of LinuxCNC#4969: - Situation has one field per line, each with a comment, and the comment above it says why it is a snapshot: the readahead at the end of emcTaskPlan() has to go by the situation the command found. - situation() uses designated initializers; its local is machineOn, so it no longer shadows the field on. - isImmediate() uses s.on, s.manual, ... instead of copying them into locals. - The new planner functions, the case blocks this PR changes in emcTaskIssueCommand() and emcTaskExecute(), and the main loop's command handling are indented with spaces. git diff -w shows only the changes above. - A comment in the main loop says how a new command is told apart and that the planner sees each command once.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The task planner refactor from #4832, with the NML commands nothing sends, split out as asked in review there. No change in behaviour except the removed commands:
breaking-changefor out-of-tree NML clients.Commits
tests/task-plannerbrings task into each situation the planner tells apart (E-stop, off, Manual, MDI idle and running, Auto idle, reading, waiting, paused) and sends it every commandemcTaskPlan()handles, one at a time. It records whether the planner issued, queued, refused or handled each one, and what situation it left task in;expectedis today's behaviour. The commands come fromtest_task_probe, a small NML client built for run-in-place only; without it the test is skipped (askipfile). This is scaffolding: each refactoring commit below leaves the table unchanged, and the last commit removes the test again.isImmediate()says once what the eight tables each repeated. 256 lines shorter; letting spindle orient through in Manual, as an example of a slip, fails the table.EMC_JOG_ABS,EMC_JOINT_HALT,EMC_JOINT_SET_FERROR,EMC_JOINT_SET_MIN_FERROR,EMC_JOINT_SET_HOMING_PARAMS,EMC_TRAJ_SET_VELOCITY,EMC_TRAJ_SET_ACCELERATION.commandWaits()andsteppingHolds()replace the pre/postcondition switches andSTEPPING_CHECK.planSpecial()), passed through (isImmediate()) or refused (refuse()).The kinematics-switch hold (#4949) and the queued-MDI READING state (#4890) from master are carried into the new switch.
Breaking changes
The seven NML command types above, and
EMCMOT_JOG_ABS, are gone. Nothing in the tree sent them.Found along the way
#4831: after a tool command in Manual or MDI, task's wait flag stays set and MDI commands are queued instead of issued until a program runs. The planner table clears the flag before each situation; the behaviour itself is left as it is.
Part of #4832, which stays open as the tracking branch.