diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index 89d1fbbb5a8..7b800c2afdd 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -739,7 +739,9 @@ static void mdi_execute_hook(void) emcTaskCommand == NULL && emcStatus->task.execState == EMC_TASK_EXEC::DONE && emcStatus->task.interpState != EMC_TASK_INTERP::IDLE && - emcStatus->motion.traj.queue == 0 && + // not traj.queue: a copy read before the controller ran after + // the move was sent still shows an empty queue + emcStatus->motion.status == RCS_STATUS::DONE && emcStatus->io.status == RCS_STATUS::DONE && !mdi_execute_wait && !mdi_execute_next) { diff --git a/tests/stale-motion-status/README b/tests/stale-motion-status/README index 993a1643a0d..f4a1b20fb04 100644 --- a/tests/stale-motion-status/README +++ b/tests/stale-motion-status/README @@ -11,7 +11,8 @@ probing" (#3650). Both tests check that the machine is on and in auto mode once wait_complete() returns, then probe at alternating heights and fail if -a probe reads the height of the one before. +a probe reads the height of the one before. Last they send MDI moves +and fail if the interpreter reads idle before a move is done. late-controller runs motion-controller before motion-command-handler, so a whole servo period passes between the two. The period is 50 ms, diff --git a/tests/stale-motion-status/test-ui.py b/tests/stale-motion-status/test-ui.py index edd6e09b2d2..2916b2e8cae 100755 --- a/tests/stale-motion-status/test-ui.py +++ b/tests/stale-motion-status/test-ui.py @@ -92,6 +92,24 @@ def error(err): sys.exit(1) time.sleep(0.05) +# An MDI move: the interpreter must not read idle before the move is done. +c.mode(linuxcnc.MODE_MDI) +c.wait_complete(60) +for x in (1, 0, 1, 0): + c.mdi("G0 X%d" % x) + start = time.time() + while True: + s.poll() + if s.interp_state == linuxcnc.INTERP_IDLE: + break + if time.time() - start > 60: + sys.stderr.write("timeout waiting for the MDI move to finish\n") + sys.exit(1) + time.sleep(0.001) + if abs(s.position[0] - x) > 1e-6: + failures.append("interpreter idle with G0 X%d at X%.4f" % (x, s.position[0])) + c.wait_complete(60) + err = e.poll() while err: error(err)