Skip to content

task: MDI is not finished while motion has yet to act on the move - #4890

Open
grandixximo wants to merge 1 commit into
LinuxCNC:masterfrom
grandixximo:mdi-idle-stale-queue
Open

grandixximo wants to merge 1 commit into
LinuxCNC:masterfrom
grandixximo:mdi-idle-stale-queue

Conversation

@grandixximo

Copy link
Copy Markdown
Contributor

A CI run failed in tests/interp/g28.2/invalid-pword: after an MDI G0 X2 the test waited for interp_state to go idle and read X at 1.068, mid-move.

Task set the interpreter idle too soon. mdi_execute_hook() takes an MDI command as finished once nothing is left to issue and motion.traj.queue is 0. Motion acknowledges a move in its command handler, but the queue depth is published by the controller, which runs later. A status copy read in between, or kept after a failed read, still shows an empty queue, so task reported idle one cycle after sending the move. The move itself ran to the end.

The fix checks motion.status == RCS_STATUS::DONE instead. Since #4666 that reads EXEC until the controller has run after the last command. It also means idle now waits for in-position, as the top-level DONE status already does.

I extended tests/stale-motion-status instead of adding a test: after the program it sends four MDI moves and fails if the interpreter reads idle before a move is at its target. The late-controller variant, where the controller runs a whole 50 ms servo period after the handler, fails on all four moves without the fix and passes with it. slow-controller passes both ways.

mdi_execute_hook() set the interpreter idle once nothing was left to
issue and the motion queue read empty.  Motion acknowledges a move in
its command handler, but the queue depth is published by the
controller, which runs later.  A status copy read in between, or kept
after a failed read, still shows an empty queue, so task reported the
MDI command finished one cycle after sending the move.  A client
waiting for interp_state to go idle then read the position mid-move;
seen on CI in tests/interp/g28.2/invalid-pword.

Use motion.status instead, which already reads EXEC until the
controller has run after the last command.

tests/stale-motion-status now sends MDI moves after the program and
fails if the interpreter reads idle before a move is done.  The
late-controller variant fails on every move without the fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant