Skip to content

Commit 78dd2b6

Browse files
committed
task: hold an MDI back while a kinematics switch is still landing
An abort routine that selects a kinematics, G13.1 in ON_ABORT_COMMAND, runs inside the interpreter at once, but its switch reaches motion later, and until it has landed the interpreter is back on the type motion still runs. An MDI arriving in that wait was read straight away under the old type: G43.4 H1 sent right after an abort found the interpreter already on the primary kinematics, queued no switch, and left G43.4 active with motion in identity. A G12.1 or G13.1 in a program or MDI line sets the wait flag, which holds an MDI back. The abort routine cannot, so task now also queues an MDI that arrives while it waits for a kinematics switch. tests/kins-switch sends G43.4 H1 right after an abort, ten times. Under load, runtests -j 4 with 8 CPU hogs in a sandbox, it failed 28 of 40 runs without the change and passed 40 of 40 with it. The full runtests suite passes.
1 parent 0abf419 commit 78dd2b6

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

‎src/emc/task/emctaskmain.cc‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,12 +1476,16 @@ static int emcTaskPlan(void)
14761476
// interp_list, and waitFlag isn't set, then this new
14771477
// incoming MDI command can just be issued directly.
14781478
// Otherwise we need to queue it and deal with it
1479-
// later.
1479+
// later. A kinematics switch task still waits on ends
1480+
// in a resynch: a line read before it is read under the
1481+
// old kinematics. The switch of an abort routine sets
1482+
// no waitFlag, so ask for it here.
14801483
if (
14811484
(mdi_execute_queue.len() == 0)
14821485
&& (interp_list.len() == 0)
14831486
&& (emcTaskCommand == NULL)
1484-
&& (emcTaskPlanIsWait() == 0)
1487+
&& (emcTaskPlanIsWait() == 0)
1488+
&& (emcStatus->task.execState != EMC_TASK_EXEC::WAITING_FOR_KINS_SWITCH)
14851489
) {
14861490
retval = emcTaskIssueCommand(emcCommand);
14871491
} else {

‎tests/kins-switch/test-ui.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,5 +481,29 @@ def param(name):
481481
else:
482482
error("could not get the machine into G55 to test the abort routine")
483483

484+
# ---- an MDI sent right after an abort is read under the routine's G13.1 ---
485+
#
486+
# The routine's switch reaches motion after the abort; a G43.4 read before
487+
# it had landed took the interpreter for already on the primary kinematics
488+
# and left motion in identity.
489+
490+
errors_before = errors
491+
for attempt in range(10):
492+
mdi("G43.4 H1")
493+
drain()
494+
c.mdi("G12.1 P-1")
495+
done(30)
496+
drain()
497+
mdi("G43.4 H1")
498+
s.poll()
499+
if 434 not in s.gcodes or kins_type() != 0:
500+
error("G43.4 H1 after an abort: G43.4 %s, kinematics type %d"
501+
% ("active" if 434 in s.gcodes else "off", kins_type()))
502+
break
503+
if errors == errors_before:
504+
print("G43.4 after an abort holds the primary kinematics")
505+
mdi("G49")
506+
mdi("G13.1")
507+
484508
print("Exiting with %d errors" % errors)
485509
sys.exit(1 if errors else 0)

0 commit comments

Comments
 (0)