From 8a2cdff9d0293df55d14de1e4a9e41b684258ade Mon Sep 17 00:00:00 2001 From: "Rev. J. Money" Date: Tue, 10 Nov 2026 01:52:00 -0500 Subject: [PATCH 1/2] task: stop at an interpreter error after the good lines have run A read error (G4 with no P fails check_items inside Interp::read) only set interpState to WAITING. The lines queued before it ran out and the program sat at the bad line with the spindle still on. An execute error did the opposite: it cleared interp_list and reset the interpreter at once, dropping the good lines read ahead of it, with no spindle or IO abort. Both now stop reading and set interp_error_pending. An execute error drops only what the bad line itself queued (new InterpList::truncate). Once interp_list, motion and IO have drained, readahead_waiting runs the abort task already uses for a motion or IO error: emcTaskAbort, emcIoAbort, emcSpindleAbort, mdi_execute_abort and emcAbortCleanup. emcAbortCleanup clears the flag, so any abort on the way cancels it. Adds g4-no-p.ngc (the program from the issue) and exec-error.ngc (G83 Q0) to tests/motion-logger/basic. Fixes #2978. --- src/emc/nml_intf/interpl.hh | 17 ++++++++++ src/emc/task/emctask.cc | 3 ++ src/emc/task/emctaskmain.cc | 31 ++++++++++++++++--- src/emc/task/task.hh | 3 ++ tests/motion-logger/basic/exec-error.ngc | 8 +++++ tests/motion-logger/basic/expected.exec-error | 22 +++++++++++++ tests/motion-logger/basic/expected.g4-no-p | 22 +++++++++++++ tests/motion-logger/basic/g4-no-p.ngc | 8 +++++ 8 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 tests/motion-logger/basic/exec-error.ngc create mode 100644 tests/motion-logger/basic/expected.exec-error create mode 100644 tests/motion-logger/basic/expected.g4-no-p create mode 100644 tests/motion-logger/basic/g4-no-p.ngc diff --git a/src/emc/nml_intf/interpl.hh b/src/emc/nml_intf/interpl.hh index a2a211d0410..b8f9112da6e 100644 --- a/src/emc/nml_intf/interpl.hh +++ b/src/emc/nml_intf/interpl.hh @@ -64,6 +64,9 @@ class InterpList void clear(); + /// Drop messages from the back until at most n remain. + void truncate(int n); + /// Number the next append() gives its message; numbers only grow. uint64_t next_number() const { return next_append; } @@ -175,6 +178,20 @@ void InterpList::append(InterpList &&other) other.linked_list.clear(); } +template +void InterpList::truncate(int n) +{ + if (n < 0) + n = 0; + if (static_cast(n) >= linked_list.size()) + return; + if (tracing()) { + printf("InterpList(%p)::truncate(%d): discarding %zu items\n", + static_cast(this), n, linked_list.size() - n); + } + linked_list.erase(linked_list.begin() + n, linked_list.end()); +} + template void InterpList::print() const { diff --git a/src/emc/task/emctask.cc b/src/emc/task/emctask.cc index e6ba142600c..8650db7f4d2 100644 --- a/src/emc/task/emctask.cc +++ b/src/emc/task/emctask.cc @@ -801,8 +801,11 @@ int emcTaskUpdate(EMC_TASK_STAT * stat) return 0; } +bool interp_error_pending = false; + int emcAbortCleanup(EMC_ABORT reason, const char *message) { + interp_error_pending = false; abortCleanupFirst = interp_list.next_number(); int status = interp.on_abort((int)reason,message); abortCleanupEnd = interp_list.next_number(); diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index 8efaa87c61d..a1dd6959a93 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -577,8 +577,13 @@ void readahead_reading(void) This if() actually evaluates to if (readRetval != INTERP_OK)... *** Need to look at all calls to things that return INTERP_xxx values! *** MGS */ - if (readRetval > INTERP_MIN_ERROR - || readRetval == INTERP_ENDFILE + if (readRetval > INTERP_MIN_ERROR) { + // Bad line: read no further, let the good lines + // already queued run, then abort (readahead_waiting). + interp_error_pending = true; + emcStatus->task.interpState = + EMC_TASK_INTERP::WAITING; + } else if (readRetval == INTERP_ENDFILE || readRetval == INTERP_EXIT || readRetval == INTERP_EXECUTE_FINISH) { /* emcTaskPlanRead retval != INTERP_OK @@ -597,17 +602,20 @@ void readahead_reading(void) emcTaskPlanCommand((char *) &emcStatus->task. command); // and execute it + int queued_before = interp_list.len(); execRetval = emcTaskPlanExecute(NULL); // line number may need update after // returns from subprograms in external // files emcStatus->task.readLine = emcTaskPlanLine(); if (execRetval > INTERP_MIN_ERROR) { + // Same as a read error: drop whatever the bad + // line itself queued, keep the good lines before + // it, and abort once they have run. + interp_list.truncate(queued_before); + interp_error_pending = true; emcStatus->task.interpState = EMC_TASK_INTERP::WAITING; - interp_list.clear(); - emcAbortCleanup(EMC_ABORT::INTERPRETER_ERROR, - "interpreter error"); } else if (execRetval == -1 || execRetval == INTERP_EXIT ) { emcStatus->task.interpState = @@ -780,6 +788,19 @@ void readahead_waiting(void) emcStatus->io.status == RCS_STATUS::DONE) // finished { + if (interp_error_pending) { + // The lines before an interpreter error have run. Stop the + // program the way an abort does (spindles, IO), so it does not + // sit at the bad line with the spindle still on. + emcTaskAbort(); + emcIoAbort(EMC_ABORT::INTERPRETER_ERROR); + for (int s = 0; s < emcStatus->motion.traj.spindles; s++) + emcSpindleAbort(s); + mdi_execute_abort(); + emcAbortCleanup(EMC_ABORT::INTERPRETER_ERROR, + "interpreter error"); + return; + } int was_open = taskplanopen; if (was_open) { emcTaskPlanClose(); diff --git a/src/emc/task/task.hh b/src/emc/task/task.hh index c1fd9496c1e..5d7ca702d68 100644 --- a/src/emc/task/task.hh +++ b/src/emc/task/task.hh @@ -21,6 +21,9 @@ extern std::unique_ptr emcTaskCommand; extern int stepping; +// An interpreter error is waiting for the good lines queued before it to +// run out; task aborts once they have. Any abort clears it. +extern bool interp_error_pending; extern int steppingWait; extern int emcTaskQueueCommand(std::unique_ptr &&cmd); extern int emcTaskOnce(const char *inifile, EMC_IO_STAT &emcioStatus); diff --git a/tests/motion-logger/basic/exec-error.ngc b/tests/motion-logger/basic/exec-error.ngc new file mode 100644 index 00000000000..a5b248bf610 --- /dev/null +++ b/tests/motion-logger/basic/exec-error.ngc @@ -0,0 +1,8 @@ +; An execute error (G83 with Q0) is handled the same way as a read error: +; the lines before it run, then task aborts and stops the spindle. +G1 X0 Y0 F100 +G1 X10 Y10 +M3 S1000 +G83 X1 Y1 Z-1 R1 Q0 +G1 X100 Y53 +M2 diff --git a/tests/motion-logger/basic/expected.exec-error b/tests/motion-logger/basic/expected.exec-error new file mode 100644 index 00000000000..29628152761 --- /dev/null +++ b/tests/motion-logger/basic/expected.exec-error @@ -0,0 +1,22 @@ +SET_LINE x=10, y=10, z=0, a=0, b=0, c=0, u=0, v=0, w=0, id=4, motion_type=2, vel=1.66667, ini_maxvel=5.65685, acc=1414.21, turn=-1 +SPINDLE_ON speed=0.000000, css_factor=0.000000, xoffset=0.000000 +SPINDLE_ON speed=1000.000000, css_factor=0.000000, xoffset=0.000000 +JOG_ABORT joint=0 +JOG_ABORT joint=1 +JOG_ABORT joint=2 +JOG_ABORT joint=3 +JOG_ABORT joint=4 +JOG_ABORT joint=5 +JOG_ABORT joint=6 +JOG_ABORT joint=7 +JOG_ABORT joint=8 +JOG_ABORT joint=9 +JOG_ABORT joint=10 +JOG_ABORT joint=11 +JOG_ABORT joint=12 +JOG_ABORT joint=13 +JOG_ABORT joint=14 +JOG_ABORT joint=15 +ABORT +SPINDLE_OFF +SS_ENABLE diff --git a/tests/motion-logger/basic/expected.g4-no-p b/tests/motion-logger/basic/expected.g4-no-p new file mode 100644 index 00000000000..f36cfd2646c --- /dev/null +++ b/tests/motion-logger/basic/expected.g4-no-p @@ -0,0 +1,22 @@ +SET_LINE x=10, y=10, z=0, a=0, b=0, c=0, u=10, v=10, w=0, id=4, motion_type=2, vel=1.66667, ini_maxvel=5.65685, acc=1414.21, turn=-1 +SPINDLE_ON speed=0.000000, css_factor=0.000000, xoffset=0.000000 +SPINDLE_ON speed=1000.000000, css_factor=0.000000, xoffset=0.000000 +JOG_ABORT joint=0 +JOG_ABORT joint=1 +JOG_ABORT joint=2 +JOG_ABORT joint=3 +JOG_ABORT joint=4 +JOG_ABORT joint=5 +JOG_ABORT joint=6 +JOG_ABORT joint=7 +JOG_ABORT joint=8 +JOG_ABORT joint=9 +JOG_ABORT joint=10 +JOG_ABORT joint=11 +JOG_ABORT joint=12 +JOG_ABORT joint=13 +JOG_ABORT joint=14 +JOG_ABORT joint=15 +ABORT +SPINDLE_OFF +SS_ENABLE diff --git a/tests/motion-logger/basic/g4-no-p.ngc b/tests/motion-logger/basic/g4-no-p.ngc new file mode 100644 index 00000000000..a914c33e6b5 --- /dev/null +++ b/tests/motion-logger/basic/g4-no-p.ngc @@ -0,0 +1,8 @@ +; #2978: G4 with no P is a read error. The lines before it run, then task +; aborts: the spindle the M3 started is stopped, not left running. +G1 X0 Y0 U0 V0 F100 +G1 X10 Y10 U10 V10 +M3 S1000 +G4 X2 +G1 X100 Y53 +M2 From 8e2fef7cc66ecb4770beedb468ae177f3017f352 Mon Sep 17 00:00:00 2001 From: "Rev. J. Money" Date: Tue, 1 Dec 2026 16:38:27 -0500 Subject: [PATCH 2/2] task: run the held moves and dwells before an interpreter error The naive CAM detector holds feed moves back to join them, so the G1 right before a bad line was not in interp_list yet and was lost. Queue the moves held from the lines before the error, and still drop what the bad line itself queued or held. A bad line with an F word flushes the held moves before it fails, so note where they end in interp_list. In a run from line the moves queued and held at a read error are of skipped lines. Drop them. The abort could also come too early: with a copy of the status read before the controller ran, traj.queue is still 0 after the last move was sent, and a dwell or input wait only shows in execState. Wait for both. Adds tests/interp-error-abort, which uses the real motion controller. --- src/emc/task/emccanon.cc | 29 ++++ src/emc/task/emctaskmain.cc | 19 ++- src/emc/task/task.hh | 7 + tests/interp-error-abort/.gitignore | 2 + tests/interp-error-abort/README | 15 +++ tests/interp-error-abort/checkresult | 3 + tests/interp-error-abort/late.hal | 5 + tests/interp-error-abort/simpockets.tbl | 1 + tests/interp-error-abort/test-ui.py | 167 ++++++++++++++++++++++++ tests/interp-error-abort/test.ini | 86 ++++++++++++ tests/interp-error-abort/test.sh | 4 + 11 files changed, 336 insertions(+), 2 deletions(-) create mode 100644 tests/interp-error-abort/.gitignore create mode 100644 tests/interp-error-abort/README create mode 100755 tests/interp-error-abort/checkresult create mode 100644 tests/interp-error-abort/late.hal create mode 100644 tests/interp-error-abort/simpockets.tbl create mode 100755 tests/interp-error-abort/test-ui.py create mode 100644 tests/interp-error-abort/test.ini create mode 100755 tests/interp-error-abort/test.sh diff --git a/src/emc/task/emccanon.cc b/src/emc/task/emccanon.cc index ec11bca6d00..93c92f12b9e 100644 --- a/src/emc/task/emccanon.cc +++ b/src/emc/task/emccanon.cc @@ -1364,13 +1364,23 @@ struct pt { static std::vector chained_points; +// Of the program line being executed, for emcCanonLineFailed(): +static size_t line_held = 0; // points held from the lines before it +static int line_queued = 0; // length of interp_list with their moves + static void drop_segments(void) { chained_points.clear(); + line_held = 0; } static void flush_segments(void) { if(chained_points.empty()) return; + // the line being executed flushes the moves from before it, and has + // queued nothing itself + const bool flushes_lines_before = line_held == chained_points.size() + && line_queued == interp_list.len(); + struct pt &pos = chained_points.back(); double x = pos.x, y = pos.y, z = pos.z; @@ -1436,6 +1446,9 @@ static void flush_segments(void) { } canonUpdateEndPoint(x, y, z, a, b, c, u, v, w); + if (flushes_lines_before) { + line_queued = interp_list.len(); + } drop_segments(); } @@ -1516,6 +1529,22 @@ void FINISH() { flush_segments(); } +void emcCanonLineStart() { + line_held = chained_points.size(); + line_queued = interp_list.len(); +} + +void emcCanonLineFailed() { + interp_list.truncate(line_queued); + chained_points.erase(chained_points.begin() + std::min(line_held, chained_points.size()), + chained_points.end()); + flush_segments(); +} + +void emcCanonDropHeld() { + drop_segments(); +} + void ON_RESET() { drop_segments(); } diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc index a1dd6959a93..9a31e8cebaa 100644 --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -580,6 +580,14 @@ void readahead_reading(void) if (readRetval > INTERP_MIN_ERROR) { // Bad line: read no further, let the good lines // already queued run, then abort (readahead_waiting). + // So do the moves canon holds back. In a run from + // line all of them are of skipped lines: drop them. + if (programStartLine != 0) { + emcCanonDropHeld(); + interp_list.clear(); + } else { + FINISH(); + } interp_error_pending = true; emcStatus->task.interpState = EMC_TASK_INTERP::WAITING; @@ -602,7 +610,7 @@ void readahead_reading(void) emcTaskPlanCommand((char *) &emcStatus->task. command); // and execute it - int queued_before = interp_list.len(); + emcCanonLineStart(); execRetval = emcTaskPlanExecute(NULL); // line number may need update after // returns from subprograms in external @@ -612,7 +620,7 @@ void readahead_reading(void) // Same as a read error: drop whatever the bad // line itself queued, keep the good lines before // it, and abort once they have run. - interp_list.truncate(queued_before); + emcCanonLineFailed(); interp_error_pending = true; emcStatus->task.interpState = EMC_TASK_INTERP::WAITING; @@ -789,6 +797,13 @@ void readahead_waiting(void) // finished { if (interp_error_pending) { + // Not traj.queue alone: a copy read before the controller + // ran after the last move was sent still shows an empty + // queue. And a dwell or an input wait shows in execState. + if (emcStatus->motion.status != RCS_STATUS::DONE || + emcStatus->task.execState != EMC_TASK_EXEC::DONE) { + return; + } // The lines before an interpreter error have run. Stop the // program the way an abort does (spindles, IO), so it does not // sit at the bad line with the spindle still on. diff --git a/src/emc/task/task.hh b/src/emc/task/task.hh index 5d7ca702d68..bcdbe983d7c 100644 --- a/src/emc/task/task.hh +++ b/src/emc/task/task.hh @@ -24,6 +24,13 @@ extern int stepping; // An interpreter error is waiting for the good lines queued before it to // run out; task aborts once they have. Any abort clears it. extern bool interp_error_pending; +// Canon holds feed moves back to join them. Task says when a program line +// starts to execute, and if it fails, that canon is to drop what the line +// queued or held, and queue the moves held from the lines before it. +// emcCanonDropHeld() is for a run from line: the lines are skipped. +extern void emcCanonLineStart(); +extern void emcCanonLineFailed(); +extern void emcCanonDropHeld(); extern int steppingWait; extern int emcTaskQueueCommand(std::unique_ptr &&cmd); extern int emcTaskOnce(const char *inifile, EMC_IO_STAT &emcioStatus); diff --git a/tests/interp-error-abort/.gitignore b/tests/interp-error-abort/.gitignore new file mode 100644 index 00000000000..849937d0988 --- /dev/null +++ b/tests/interp-error-abort/.gitignore @@ -0,0 +1,2 @@ +isub.ngc +test.ngc diff --git a/tests/interp-error-abort/README b/tests/interp-error-abort/README new file mode 100644 index 00000000000..a1b0dac911d --- /dev/null +++ b/tests/interp-error-abort/README @@ -0,0 +1,15 @@ +The lines before an interpreter error run, then task aborts (#2978). + +Each program ends in a line that fails in the interpreter, as it is read +or as it is executed. The test fails if the machine does not reach the +last point before that line, if the spindle stays on, or if a dwell +before it is cut short. + +Canon holds feed moves back to join them, so the last one is not in +interp_list yet when the error is found. In a run from line those held +back belong to skipped lines, and must not run. + +This uses the real motion controller, with motion-controller before +motion-command-handler and a 50 ms period as in +tests/stale-motion-status/late-controller, so that a status read in +between still shows an empty queue. diff --git a/tests/interp-error-abort/checkresult b/tests/interp-error-abort/checkresult new file mode 100755 index 00000000000..acfd40f1b32 --- /dev/null +++ b/tests/interp-error-abort/checkresult @@ -0,0 +1,3 @@ +#!/bin/sh +# Test passes if test-ui.py returns successfully +exit 0 diff --git a/tests/interp-error-abort/late.hal b/tests/interp-error-abort/late.hal new file mode 100644 index 00000000000..104b629402f --- /dev/null +++ b/tests/interp-error-abort/late.hal @@ -0,0 +1,5 @@ +# Run the controller before the command handler, so that motion +# acknowledges a command a whole servo period before the controller +# acts on it. +delf motion-command-handler servo-thread +addf motion-command-handler servo-thread 2 diff --git a/tests/interp-error-abort/simpockets.tbl b/tests/interp-error-abort/simpockets.tbl new file mode 100644 index 00000000000..0bdf35afecc --- /dev/null +++ b/tests/interp-error-abort/simpockets.tbl @@ -0,0 +1 @@ +T1 P1 Z0.0 D0.0 ; diff --git a/tests/interp-error-abort/test-ui.py b/tests/interp-error-abort/test-ui.py new file mode 100755 index 00000000000..aefc166c838 --- /dev/null +++ b/tests/interp-error-abort/test-ui.py @@ -0,0 +1,167 @@ +#!/usr/bin/env python3 + +import linuxcnc +import sys +import time + +c = linuxcnc.command() +s = linuxcnc.stat() +e = linuxcnc.error_channel() + +failures = [] + + +def finish(): + for msg in failures: + sys.stderr.write("error: " + msg + chr(10)) + sys.exit(1 if failures else 0) + + +def wait(what, done, timeout=60): + start = time.time() + while True: + s.poll() + if done(): + return + if time.time() - start > timeout: + failures.append("timeout waiting for " + what) + finish() + time.sleep(0.01) + + +def drain(): + errors = [] + while True: + err = e.poll() + if not err: + return errors + if "Unexpected realtime delay" not in err[1]: + errors.append(err[1]) + + +def start(lines, from_line=0): + """home the axes to X0 Y0, then run a program of these lines""" + c.mode(linuxcnc.MODE_MDI) + c.wait_complete(60) + c.mdi("G20 G90 G64 G80 G0 X0 Y0 Z0") + c.wait_complete(60) + wait("X0", lambda: abs(s.position[0]) < 1e-6 and abs(s.position[1]) < 1e-6) + drain() + with open("test.ngc", "w") as f: + f.write("\n".join(lines) + "\n") + c.mode(linuxcnc.MODE_AUTO) + c.wait_complete(60) + c.program_open("test.ngc") + c.auto(linuxcnc.AUTO_RUN, from_line) + + +def check(name, lines, x, y=0, min_time=0, from_line=0): + """run the lines: task must report an error and end with the interpreter + idle, the spindle off and the machine at x, y""" + start(lines, from_line) + errors = [] + + def reported(): + errors.extend(drain()) + return errors + wait("the error of " + name, reported) + reported_at = time.time() + wait("the end of " + name, + lambda: s.interp_state == linuxcnc.INTERP_IDLE) + took = time.time() - reported_at + if abs(s.position[0] - x) > 1e-6 or abs(s.position[1] - y) > 1e-6: + failures.append("%s: ended at X%.4f Y%.4f, before X%g Y%g" % ( + name, s.position[0], s.position[1], x, y)) + time.sleep(0.5) + s.poll() + if abs(s.position[0] - x) > 1e-6 or abs(s.position[1] - y) > 1e-6: + failures.append("%s: at X%.4f Y%.4f, not X%g Y%g" % ( + name, s.position[0], s.position[1], x, y)) + if s.spindle[0]["enabled"]: + failures.append("%s: the spindle is on" % name) + c.abort() + c.wait_complete(60) + if took < min_time: + failures.append("%s: ended %.2f s after the error, not %g s" % ( + name, took, min_time)) + + +c.state(linuxcnc.STATE_ESTOP_RESET) +c.wait_complete(60) +c.state(linuxcnc.STATE_ON) +c.wait_complete(60) +for joint in range(3): + c.home(joint) + wait("joint %d to home" % joint, lambda: s.homed[joint] + and not any(j["homing"] for j in s.joint[:3])) + +read_error = "G4" +exec_error = "G83 X0 Y0 Z-1 R0 Q0" +arc_error = "G2 X9 Y0 I0.1 J0" +for kind, bad in (("read", read_error), ("exec", exec_error), + # its F word flushes the move canon holds back + ("exec, F word", exec_error + " F20"), + # nothing before the error flushes it + ("exec, arc", arc_error)): + # slow moves: an abort stops each joint first, a period for each, and a + # fast move is over before the abort gets to it + for name, good, x, y in ( + ("G0", ["G0 X1"], 1, 0), + ("G1", ["G1 X1 F30"], 1, 0), + # in line: canon holds both back as one move + ("joined G1", ["G1 X0.5 F30", "G1 X1"], 1, 0), + ("corner G1", ["G1 X1 F30", "G1 Y1"], 1, 1), + ("dwell, G1", ["G4 P0.2", "G1 X1 F30"], 1, 0)): + check(kind + " error after " + name, + ["G20 G90 G64 P0.01", "M3 S100"] + good + [bad, "G0 X3", "M2"], + x, y) + # the dwell runs to its end + check(kind + " error after a dwell", + ["G20 G90", "M3 S100", "G0 X1", "G4 P2", bad, "G0 X3", "M2"], + 1, 0, min_time=1.5) + check(kind + " error, no move before it", + ["G20 G90", "M3 S100", bad, "G0 X3", "M2"], 0) + + if kind not in ("read", "exec"): + continue + # Run from line 7: lines 1 to 6 are skipped, so the G1 canon holds back + # when the error is found must not run. + check(kind + " error in the lines skipped", + ["G20 G90 G64 P0.01", "F300", "G1 X1", bad, "G4 P0", "G4 P0", + "G0 X3", "M2"], 0, from_line=7) + # the same in a subroutine, where task does not clear what is queued + check(kind + " error in a subroutine skipped", + ["o100 sub", bad, "o100 endsub", "G20 G90 G64 P0.01", "F300", + "G1 X1", "o100 call", "G4 P0", "G4 P0", "G0 X3", "M2"], + 0, from_line=10) + check(kind + " error after a move in a subroutine skipped", + ["o100 sub", "G1 X1", bad, "o100 endsub", "G20 G90 G64 P0.01", + "F300", "o100 call", "G4 P0", "G4 P0", "G0 X3", "M2"], + 0, from_line=10) + check(kind + " error after a G0 in a subroutine skipped", + ["o100 sub", "G0 X1", bad, "o100 endsub", "G20 G90 G64 P0.01", + "F300", "o100 call", "G4 P0", "G4 P0", "G0 X3", "M2"], + 0, from_line=10) + + # in a file of its own, the line numbers are past the line to run from + for name, move in (("G0", "G0 X1"), ("G1", "G1 X1 F300")): + with open("isub.ngc", "w") as f: + f.write("\n".join(["o sub"] + ["G4 P0"] * 20 + + [move, bad, "o endsub", "M2"]) + "\n") + check("%s error after %s in a file skipped" % (kind, name), + ["G20 G90 G64 P0.01", "o call", "G4 P0", "G4 P0", + "G0 X3", "M2"], 0, from_line=5) + +# The pending error goes with an abort: the next program runs to its end. +start(["G20 G90", "G1 X1 F10", read_error, "M2"]) +wait("the move", lambda: s.position[0] > 0.05) +c.abort() +c.wait_complete(60) +start(["G20 G90", "G1 X2 F300", "M2"]) +time.sleep(0.5) +wait("the program", lambda: s.interp_state == linuxcnc.INTERP_IDLE) +if abs(s.position[0] - 2) > 1e-6: + failures.append("after an abort: at X%.4f, not X2" % s.position[0]) +failures += ["after an abort: " + err for err in drain()] + +finish() diff --git a/tests/interp-error-abort/test.ini b/tests/interp-error-abort/test.ini new file mode 100644 index 00000000000..37d0a53f161 --- /dev/null +++ b/tests/interp-error-abort/test.ini @@ -0,0 +1,86 @@ +[EMC] +VERSION = 1.1 +DEBUG = 0x0 + +[DISPLAY] +DISPLAY = ./test-ui.py + +[TASK] +TASK = milltask +CYCLE_TIME = 0.001 + +[RS274NGC] +PARAMETER_FILE = sim.var + +[EMCMOT] +EMCMOT = motmod +COMM_TIMEOUT = 4.0 +BASE_PERIOD = 0 +SERVO_PERIOD = 50000000 + +[EMCIO] +TOOL_TABLE = simpockets.tbl + +[HAL] +HALFILE = LIB:core_sim.hal +HALFILE = late.hal + +[TRAJ] +NO_FORCE_HOMING = 1 +COORDINATES = X Y Z +LINEAR_UNITS = inch +ANGULAR_UNITS = degree +DEFAULT_LINEAR_VELOCITY = 10 +MAX_LINEAR_VELOCITY = 100 + +[KINS] +KINEMATICS = trivkins +JOINTS = 3 + +[AXIS_X] +MIN_LIMIT = -40.0 +MAX_LIMIT = 40.0 +MAX_VELOCITY = 100 +MAX_ACCELERATION = 10000.0 + +[JOINT_0] +TYPE = LINEAR +HOME = 0.0 +MAX_VELOCITY = 100 +MAX_ACCELERATION = 10000.0 +MIN_LIMIT = -40.0 +MAX_LIMIT = 40.0 +FERROR = 0.050 +MIN_FERROR = 0.010 + +[AXIS_Y] +MIN_LIMIT = -40.0 +MAX_LIMIT = 40.0 +MAX_VELOCITY = 100 +MAX_ACCELERATION = 10000.0 + +[JOINT_1] +TYPE = LINEAR +HOME = 0.0 +MAX_VELOCITY = 100 +MAX_ACCELERATION = 10000.0 +MIN_LIMIT = -40.0 +MAX_LIMIT = 40.0 +FERROR = 0.050 +MIN_FERROR = 0.010 + +[AXIS_Z] +MIN_LIMIT = -40.0 +MAX_LIMIT = 40.0 +MAX_VELOCITY = 100 +MAX_ACCELERATION = 10000.0 + +[JOINT_2] +TYPE = LINEAR +HOME = 0.0 +MAX_VELOCITY = 100 +MAX_ACCELERATION = 10000.0 +MIN_LIMIT = -40.0 +MAX_LIMIT = 40.0 +FERROR = 0.050 +MIN_FERROR = 0.010 diff --git a/tests/interp-error-abort/test.sh b/tests/interp-error-abort/test.sh new file mode 100755 index 00000000000..1f7aa8c808a --- /dev/null +++ b/tests/interp-error-abort/test.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -e + +linuxcnc -r test.ini