From 887f9843152263eca1207a53f150b695b5a939cf Mon Sep 17 00:00:00 2001 From: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> Date: Wed, 2 Dec 2026 20:31:48 +1100 Subject: [PATCH] task: report a queued MDI as not idle When an MDI arrives while task is still busy, for instance with the cleanup after an abort, task puts it in its MDI queue and runs it later. The status that echoes the command still showed the interpreter idle, so a client that sends an MDI and then waits for idle returned at once and read the machine before the command had run. tests/interp/g28.2/invalid-pword did exactly that and failed on the i386 CI job of #4942: "coordinated motion did not survive the rejected Pn (X stayed at 0.9999999999999999)", X still at 1 from the G0 X1 before. Task now sets the interpreter state to reading when it queues an MDI, as it does when it runs one straight away. It goes back to idle once the queued command has run, as before. The test no longer sleeps after its mode switches: task applies a mode in the cycle that echoes it, so the next command already sees it. Tested in a sandbox under load, runtests -j 8 with 8 CPU hogs: the test as it is on master failed 6 times in 220 runs, and passed 220 of 220 with this change; the test from this commit passed 240 of 240. The full runtests suite passes. --- src/emc/task/emctaskmain.cc | 3 +++ tests/interp/g28.2/invalid-pword/test-ui.py | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index 8efaa87c61d..ec3d862b0f6 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -1489,6 +1489,9 @@ static int emcTaskPlan(void) rtapi_strlcpy(cmd->command, static_cast(emcCommand)->command, sizeof(cmd->command)); mdi_execute_queue.append(std::move(cmd)); emcStatus->task.queuedMDIcommands = mdi_execute_queue.len(); + // not idle while an MDI waits its turn: the status + // that echoes it must not read as done + emcStatus->task.interpState = EMC_TASK_INTERP::READING; retval = 0; } break; diff --git a/tests/interp/g28.2/invalid-pword/test-ui.py b/tests/interp/g28.2/invalid-pword/test-ui.py index 19effdd827e..7acbaa89fcb 100755 --- a/tests/interp/g28.2/invalid-pword/test-ui.py +++ b/tests/interp/g28.2/invalid-pword/test-ui.py @@ -187,7 +187,6 @@ def mode_name(m): # unrelated complaint about extra joints. drain_errors() c.mode(linuxcnc.MODE_MANUAL) -time.sleep(0.2) c.unhome(3) time.sleep(0.5) poll() @@ -201,9 +200,6 @@ def mode_name(m): fail("an immediate unhome of unconfigured joint 3 disturbed a real joint: {}".format(list(s.homed[:3]))) print("PASS: immediate unhome of an unconfigured joint reported {!r}".format(msgs[0][:90])) -c.mode(linuxcnc.MODE_MDI) -time.sleep(0.2) - # The rejection must not have cost anything: ordinary work continues. c.mode(linuxcnc.MODE_MDI) c.mdi("G0 X2")