Skip to content

task: halui's pins in task - #4832

Draft
rene-dev wants to merge 28 commits into
LinuxCNC:masterfrom
rene-dev:task-hal
Draft

rene-dev wants to merge 28 commits into
LinuxCNC:masterfrom
rene-dev:task-hal

Conversation

@rene-dev

@rene-dev rene-dev commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Tracking PR. This branch carries all of the work below, rebased on master, and stays open as the place to see it together. It is split for review and merging into:

  1. gscreen startup crash; joints at rest before entering joint mode #4968 — gscreen startup crash; joints at rest before entering joint mode (on master alone)
  2. task: planner refactor, remove unused NML commands #4969 — task planner refactor, unused NML commands removed (breaking-change)
  3. task: halui's pins in task (task.*) #4970 — halui's pins in task (task.*), on task: planner refactor, remove unused NML commands #4969
  4. jog while paused, and return to the paused position on resume #4971 — jog while paused, on task: halui's pins in task (task.*) #4970
  5. task: the task mode follows what runs #4972 — modeless task, on jog while paused, and return to the paused position on resume #4971
  6. remove EMC_TASK_SET_MODE and halui's mode request pins #4973 — remove EMC_TASK_SET_MODE and the halui.mode.* request pins (breaking-change), on task: the task mode follows what runs #4972

Please review there. The description below is the original one, for the first part of the work.

This is the first step towards removing halui: task exports the halui pins
that motion and iocontrol don't already have, as a HAL component task
with halui's pin names under task.. Overrides, MDI commands, jogging and
joint/axis selection follow in later PRs; halui is untouched here and keeps
working.

The first three commits are groundwork with no change in behaviour, and the
first one is what shows that.

Commits

  1. tests: record what the task planner does with every command
    tests/task-planner brings task into each situation the planner tells
    apart (E-stop, off, Manual, MDI idle and running, Auto idle, reading,
    waiting, paused) and sends it every command emcTaskPlan() handles, one
    at a time. From task's own debug output it records whether the planner
    issued the command, queued it, refused it or handled it itself, and what
    situation the command left task in. expected is today's behaviour, so a
    change to the planner either leaves the table alone or shows up as a diff
    of it. The commands come from test_task_probe, a small NML client built
    for run-in-place only (not installed; the test skips without it). About
    a minute. It is scaffolding for the refactoring of task that follows
    (this PR and the modeless task); once that is done, the test and
    test_task_probe are removed again.
  2. task: hand emcTaskPlan() the new command
    The main loop decides whether there is a new command and passes it, or
    NULL; the planner no longer reads the NML buffer itself. This is what
    lets a command reach the planner another way. Table unchanged.
  3. task: one list of immediate commands for the planner tables
    The eight tables repeated the commands each passes straight to
    emcTaskIssueCommand(). isImmediate() says this once, by state, mode
    and interpreter state; each table keeps only what is special to it and
    its refusal message. 256 lines shorter. Table unchanged; letting spindle
    orient through in Manual, as an example of a slip, fails the test.
  4. task: export halui's status pins that motion and iocontrol lack
    The task component and its status pins (table below). task.tool.diameter
    reads the loaded tool's entry from the status, as halui does since
    7412d9d, so task's pins need no tool table access. Updated once per
    task cycle from task's own status, so current in the same cycle where
    halui's lag by its poll. The component is created before inihal is
    ready, because the linuxcnc script runs the HAL files as soon as it is:
    HAL files can connect task.* pins, as they can halui's.
    tests/task-hal-pins connects some in a HAL file and compares every one
    with halui's pin in Manual, teleop, MDI with offsets and tools, with
    overrides, and while a program runs and is paused.
  5. task: halui's command pins, as task-internal commands
    The command inputs. Like halui's they act on the rising edge and send
    the same commands, but not through NML: emcTaskQueueInternalCommand()
    queues them and the main loop hands one to emcTaskPlan() on each cycle
    without a new NML command. They leave the echo serial number alone, a
    refused one is reported on the error channel only, and none of them
    changes the status of the UI's last command. tests/task-hal-inputs
    pulses each pin without halui and checks both.
  6. task: the halui pins whose iocontrol counterpart differs
    task.estop.is-activated (iocontrol's is inverted), task.estop.activate
    (iocontrol's is a level, not an edge) and task.tool.number (iocontrol's
    is signed). With these, a configuration can be moved off halui's covered
    pins by renaming alone.

Every commit builds and passes the task, halui, abort, linuxcncrsh,
mdi-queue and toolchanger tests on its own.

Difference from halui

No task.mode.manual / .auto / .mdi: task's mode is to follow what
task runs rather than be set (the modeless task work). task.program.run
switches to Auto first, as halui does.

Found along the way

#4831: after a tool command in Manual or MDI, task's wait flag stays set and
MDI commands are queued instead of issued until a program runs. The planner
test clears the flag before each situation so that no cell depends on
earlier probes; the behaviour itself is left as it is here.

halui's pins and where they go

✅ the same signal already exists elsewhere · ◐ partly, or with different
semantics · ❌ nothing. The last column is the task.* pin from this PR, or
where the rest is planned to go.

Status outputs

halui pin type alternative task pin
halui.machine.is-on bool motion.motion-enabled ✅ —
halui.machine.units-per-mm real — (INI constant) ❌ task.machine.units-per-mm
halui.estop.is-activated bool iocontrol.0.user-enable-out (inverted) ◐ task.estop.is-activated
halui.mode.is-manual bool — ❌ task.mode.is-manual
halui.mode.is-auto bool — ❌ task.mode.is-auto
halui.mode.is-mdi bool — ❌ task.mode.is-mdi
halui.mode.is-teleop bool motion.teleop-mode ✅ —
halui.mode.is-joint bool motion.teleop-mode/motion.coord-mode both false ◐ task.mode.is-joint
halui.mist.is-on bool iocontrol.0.coolant-mist ✅ —
halui.flood.is-on bool iocontrol.0.coolant-flood ✅ —
halui.program.is-idle bool — ❌ task.program.is-idle
halui.program.is-running bool — ❌ task.program.is-running
halui.program.is-paused bool — ❌ task.program.is-paused
halui.program.optional-stop.is-on bool — ❌ task.program.optional-stop.is-on
halui.program.block-delete.is-on bool — ❌ task.program.block-delete.is-on
halui.halui-mdi-is-running bool — (halui-internal state) ❌ later (task), with the MDI commands
halui.max-velocity.value real — ❌ task.max-velocity.value
halui.feed-override.value real — ❌ task.feed-override.value
halui.rapid-override.value real — ❌ task.rapid-override.value
halui.spindle.S.is-on bool spindle.S.on ✅ —
halui.spindle.S.runs-forward bool spindle.S.forward ✅ —
halui.spindle.S.runs-backward bool spindle.S.reverse ✅ —
halui.spindle.S.brake-is-on bool spindle.S.brake ✅ —
halui.spindle.S.override.value real — ❌ task.spindle.S.override.value
halui.joint.N.is-homed bool joint.N.homed ✅ —
halui.joint.N.has-fault bool joint.N.faulted ✅ —
halui.joint.N.on-hard-min-limit bool joint.N.neg-hard-limit ✅ —
halui.joint.N.on-hard-max-limit bool joint.N.pos-hard-limit ✅ —
halui.joint.N.on-soft-min-limit bool motion.on-soft-limit (global only) ◐ task.joint.N.on-soft-min-limit
halui.joint.N.on-soft-max-limit bool motion.on-soft-limit (global only) ◐ task.joint.N.on-soft-max-limit
halui.joint.N.override-limits bool — ❌ task.joint.N.override-limits
halui.joint.N.is-selected bool — (halui selection state) ❌ later (selection)
halui.joint.selected uint — (halui selection state) ❌ later (selection)
halui.joint.selected.{is-homed,has-fault,on-*-limit,override-limits} bool — (mux of the above by selection) ❌ later (selection)
halui.axis.L.is-selected bool — (halui selection state) ❌ later (selection)
halui.axis.selected uint — (halui selection state) ❌ later (selection)
halui.axis.L.pos-commanded real axis.L.pos-cmd ✅ —
halui.axis.L.pos-feedback real — (only joint-space joint.N.pos-fb) ◐ task.axis.L.pos-feedback
halui.axis.L.pos-relative real — (needs G5x/G92/G68/tool offsets) ❌ task.axis.L.pos-relative
halui.tool.number uint iocontrol.0.tool-number (sint) ◐ task.tool.number
halui.tool.length_offset.{x..w} real motion.tooloffset.{x..w} ✅ —
halui.tool.diameter real — ❌ task.tool.diameter

Command inputs

halui pin type alternative task pin
halui.machine.on / .off bool — ❌ task.machine.on / .off
halui.estop.activate bool iocontrol.0.emc-enable-in low (a level that holds E-stop, not an edge) ◐ task.estop.activate
halui.estop.reset bool — ❌ task.estop.reset
halui.mode.manual / .auto / .mdi bool — ❌ none: task's mode is to follow what task runs (task-modeless)
halui.mode.teleop / .joint bool — ❌ task.mode.teleop / .joint
halui.mist.on / .off bool — ❌ task.mist.on / .off
halui.flood.on / .off bool — ❌ task.flood.on / .off
halui.program.run bool — ❌ task.program.run
halui.program.pause / .resume bool motion.feed-hold (needs M53) / motion.feed-inhibit — motion-level hold, not a task pause ◐ task.program.pause / .resume
halui.program.step bool — ❌ task.program.step
halui.program.stop bool — ❌ task.program.stop
halui.abort bool — (motion.jog-stop only stops jogs) ❌ task.abort
halui.program.optional-stop.on / .off bool — ❌ task.program.optional-stop.on / .off
halui.program.block-delete.on / .off bool — ❌ task.program.block-delete.on / .off
halui.home-all bool — ❌ task.home-all (only with [JOINT_0]HOME_SEQUENCE, like halui)
halui.joint.N.home / .unhome bool — ❌ task.joint.N.home / .unhome
halui.joint.selected.home / .unhome bool — ❌ later (selection)
halui.mdi-command-NN bool — ❌ later (task)
halui.max-velocity.{counts,count-enable,direct-value,scale,increase,decrease} sint/bool/real ini.traj_max_velocity (changes the limit, not the runtime value) ◐ later (task)
halui.feed-override.{counts,count-enable,direct-value,scale,increase,decrease,reset} sint/bool/real motion.adaptive-feed (scales feed, but invisible to GUIs, not an override) ◐ later (task)
halui.rapid-override.{counts,count-enable,direct-value,scale,increase,decrease,reset} sint/bool/real — ❌ later (task)
halui.spindle.S.override.{counts,count-enable,direct-value,scale,increase,decrease,reset} sint/bool/real — ❌ later (task)
halui.spindle.S.start / .stop bool — (spindle.S.inhibit can only block) ❌ task.spindle.S.start / .stop
halui.spindle.S.forward / .reverse bool — ❌ task.spindle.S.forward / .reverse
halui.spindle.S.increase / .decrease bool — ❌ task.spindle.S.increase / .decrease
halui.spindle.S.brake-on / .brake-off bool — ❌ task.spindle.S.brake-on / .brake-off
halui.joint.N.select bool — (halui selection state) ❌ later (selection)
halui.axis.L.select bool — (halui selection state) ❌ later (selection)
halui.joint.N.plus / .minus bool — (continuous jog) ❌ later (motion)
halui.joint.N.analog real — (velocity jog) ❌ later (motion)
halui.joint.N.increment + .increment-plus / .increment-minus real/bool joint.N.jog-counts + jog-scale + jog-enable (wheel jog; a pulse per press ≈ increment) ◐ later (motion)
halui.joint.selected.{plus,minus,increment,increment-plus,increment-minus} bool/real — ❌ later (selection)
halui.joint.jog-speed / .jog-deadband real — (config for the above) ❌ later (motion)
halui.axis.L.plus / .minus bool — ❌ later (motion)
halui.axis.L.analog real — ❌ later (motion)
halui.axis.L.increment + .increment-plus / .increment-minus real/bool axis.L.jog-counts + jog-scale + jog-enable ◐ later (motion)
halui.axis.selected.{plus,minus,increment,increment-plus,increment-minus} bool/real — ❌ later (selection)
halui.axis.jog-speed / .jog-deadband real — ❌ later (motion)

@grandixximo

Copy link
Copy Markdown
Contributor
  • tests/task-planner/test.sh:4: without test_task_probe it exits 0, then checkresult finds no probes and fails, so the package jobs fail. An executable skip file is what runtests uses for this: it runs the test when the file exits 0, so #!/bin/sh plus command -v test_task_probe >/dev/null would do.
  • tests/task-planner/test-ui.py:209: time.sleep(0.05) then reads the situation, 711 times. Under -j load a state change after 50 ms records - and the table differs. Wait on the probe-end message plus a settled status instead? That should also cut most of the minute.
  • tests/task-hal-inputs/test-ui.py:51: pulse() holds the pin high for 50 ms. Task sees an edge only if one of its cycles falls inside that window, so under -j load a pulse can be missed and press() times out. Hold it until cond() is true, then drop it? And line 120: time.sleep(0.2) before checking that the refused program.step left the status alone; waiting for the refusal on the error channel would prove task has handled it first.
  • tests/task-hal-pins and tests/task-hal-inputs: the two .ini files differ only in HALUI, the HAL file and HOME_SEQUENCE. Could they be one test, inputs first without halui, then the pins with it? Bertho raised the test count on task: an E-stop reset leaves a machine that is on alone #4801 (264 in 2.9, 360 on master).
  • emctaskmain.cc:3365: an internal command leaves the echo serial alone, but status follows the global state. With halui, its command bumps the serial and a GUI's wait_complete() returns; here a GUI waiting on its own command sees its serial with EXEC while a HAL-started program runs. Does a GUI then time out?
  • taskhal.cc:490: estop.activate is an edge, queued behind other internal commands and behind any NML command that cycle. Same as halui, but worth saying in the docs that it is not a safety input, so nobody "renames" iocontrol.0.emc-enable-in to it.
  • The table probes 79 commands; EMC_TOOL_PREPARE, EMC_SYSTEM_CMD, EMC_TRAJ_LINEAR_MOVE and EMC_JOINT_ACTIVATE are never sent, and there is no E-stop-in-MDI or MDI-paused situation. If it is to guard the modeless rework, add those?
  • Textual overlap with task: report the serial of a command that failed #4817 (failed serial) around emctaskmain.cc:3360; and modeless task, and jog-while-paused #4700 (modeless) rewrites the same main loop.

@grandixximo

Copy link
Copy Markdown
Contributor

I think this should be split now that the modeless work is in it:

  1. Standalone fixes: the gscreen crash (c9f8e95) and the joints at rest before joint mode (7913b1e). The latter happens on master too: a joint mode request sent during an MDI G0 leaves the joint short by up to 0.004 mm, every time, and your commit fixes it.
  2. The planner refactor and the dead NML commands (breaking-change for out-of-tree clients).
  3. halui's pins in task.
  4. Modeless task and jog while paused, with the pause coolant fix that builds on it. Removing EMC_TASK_SET_MODE and halui.mode.* reopens the modeless task, and jog-while-paused #4700 mode question and deserves its own PR.

Still open from my earlier list: pulse() 50 ms can miss a task cycle under load, the two hal tests could be one, wait_complete() during a HAL-started run, and a note that task.estop.activate is not a safety input.

@rene-dev

rene-dev commented Dec 6, 2026

Copy link
Copy Markdown
Member Author

Thanks, split as you suggested; this PR stays open as the tracking branch, rebased on master:

  1. gscreen startup crash; joints at rest before entering joint mode #4968 — the gscreen crash and the joints at rest before joint mode
  2. task: planner refactor, remove unused NML commands #4969 — planner refactor and the dead NML commands (breaking-change)
  3. task: halui's pins in task (task.*) #4970 — halui's pins in task
  4. jog while paused, and return to the paused position on resume #4971 — jog while paused
  5. task: the task mode follows what runs #4972 — modeless task, with the pause coolant fix; it carries the joints-at-rest commit from gscreen startup crash; joints at rest before entering joint mode #4968 too, since every run end now switches motion back to joint or world mode
  6. remove EMC_TASK_SET_MODE and halui's mode request pins #4973 — EMC_TASK_SET_MODE and halui.mode.* removal on its own (breaking-change)

On your points:

  • task-planner without test_task_probe: it has a skip file now. The table is removed at the end of task: planner refactor, remove unused NML commands #4969 anyway, so its 50 ms sleeps, the commands it doesn't send and the missing situations no longer matter after that PR.
  • pulse() 50 ms: an input is now held until task has acted on it, then kept low until task has run two more cycles (stat.taskbeat). The refused program.step waits for the refusal on the error channel instead of 200 ms.
  • task-hal-pins and task-hal-inputs: one test, tests/task-hal: inputs first without halui, then halui is loaded with halcmd loadusr and the pins are compared.
  • wait_complete() during a HAL-started run: yes, a GUI that waits on its own command while a pin-started program runs waits for the run, and with a 5 s timeout it gets a timeout. With halui, the NML run command was newer than the GUI's, so the wait returned DONE as soon as halui sent it. A GUI that waits on a command sent while another client's program runs already waits like that, so the difference is the window in which the pin starts a run while the GUI's own command is still in progress. Giving pin commands a serial of their own would collide with the next NML serial, so I left it and documented it in milltask(1).
  • task.estop.activate: milltask(1) now lists the task.* pins and says it is an edge handled in task's next cycle, not a safety input, and that the E-stop chain belongs on iocontrol.0.emc-enable-in and in hardware.
  • task: report the serial of a command that failed #4817 / modeless task, and jog-while-paused #4700: rebased over task: report the serial of a command that failed #4817. task: report a queued MDI as not idle #4949's kinematics-switch hold needed one change in the modeless planner: an MDI from idle now goes through the same queue check, so it waits for an abort routine's G13.1 (tests/kins-switch).

@grandixximo

Copy link
Copy Markdown
Contributor

The armhf failure here (gmoccapy-quit, qtdragon-quit, touchy-quit) is a test bug on runners that fall back to QEMU, fixed in #4965. The next push picks up the fix. The hard-limits failure on bookworm is a separate one.

tests/task-planner brings task into each situation its planner tells
apart (E-stop, off, Manual, MDI idle and running, Auto idle, reading,
waiting and paused) and sends it every command emcTaskPlan() handles,
one at a time, plus one it has no case for. From task's own debug output
it records, for each, whether the planner issued the command, queued it
for later, refused it or handled it itself, and what situation the
command left task in. The table is compared with tests/task-planner/
expected, which is the behaviour of today's planner.

A change to the planner that is not meant to change behaviour leaves the
table as it is; one that is shows up as a diff of it.

The commands come from test_task_probe, a small NML client that sends
any of them with arguments that change as little as possible. It is
built for run-in-place only and not installed; the test skips without
it.
emcTaskPlan() found its command itself: it compared emcCommand's serial
number with the echoed one to tell a new command from none, and
allow_while_idle_type() read the command's type from the NML buffer once
more. Have the main loop make that decision and pass the new command,
or NULL, and use only that inside the planner.

This is what lets a command reach the planner by another way than the
NML buffer. No change in behaviour: tests/task-planner is unchanged.
The planner's tables repeated the commands each passes straight to
emcTaskIssueCommand(): 22 accepted in any state, three more only while
the machine is off, twelve once it is on, the spindle commands unless a
program is reading or waiting, the program and I/O commands unless one
runs, and so on. isImmediate() now says this once, by the state, mode
and interpreter state task is in, and each table keeps only what is
special to it and its own refusal. allow_while_idle_type() is part of
it now, and the three tool commands share queueToolCommand().

No change in behaviour: tests/task-planner is unchanged, and fails if
spindle orient is let through in Manual, as an example of a slip.
EMC_JOG_ABS, EMC_JOINT_HALT, EMC_JOINT_SET_FERROR, EMC_JOINT_SET_MIN_FERROR,
EMC_JOINT_SET_HOMING_PARAMS, EMC_TRAJ_SET_VELOCITY and
EMC_TRAJ_SET_ACCELERATION, with their classes, task's handling of them and
their rows in the planner table. emcJogAbs() had no other caller.
… of checkInterpList()

checkInterpList() lost its limit checks long ago and always returned 0; it
now only shows the operator errors of the lines it drops. task read
[TASK]MDI_QUEUED_COMMANDS and never used it.
42 file-level pointers each held the cast for one case. Those used once
are folded into the call; the others are declared in their case.
emcTaskCheckPreconditions() and emcTaskCheckPostconditions() become
commandWaits(), and the STEPPING_CHECK macro becomes steppingHolds(). The
table says what the two switches said, command for command.
emcTaskPlan() works out the situation once, then a command is handled by
the planner itself (planSpecial()), passed straight through
(isImmediate()) or refused (refuse()). The planner table is unchanged.
With EMC_JOG_ABS and emcJogAbs() gone the handler had no caller. In teleop
it was not absolute either: axis_jog_abs() added the target to the current
position.
tests/task-planner and test_task_probe recorded what the planner did with
every command, to show that the refactoring of emcTaskPlan() changed
nothing. That work is done.
Task gets a HAL component, "task", with the status pins of halui that
have no equivalent elsewhere: the task mode and whether motion is in
joint mode, the interpreter state, optional stop and block delete, the
override and max-velocity values, the soft limits and override-limits
of each joint, each axis' Cartesian feedback and relative (DRO)
position, the tool diameter and units-per-mm. Their names are halui's
under "task." instead of "halui.".

They are updated once per task cycle from task's own status, so they
are current in the same cycle, where halui's lag by its poll.

The component is created before inihal is ready, so that the HAL files,
which the linuxcnc script runs as soon as inihal is, can connect its
pins, as they can halui's. The axes and spindles are therefore read from
the INI file, the way task sets motion up with them.

tests/task-hal-pins connects some of the pins in a HAL file, and
compares every one of them with halui's pin in manual, teleop, MDI with
offsets and tools, with overrides, and while a program runs and is
paused.
Task exports halui's command input pins: machine on/off, E-stop reset,
teleop/joint mode, mist and flood, program run/pause/resume/step/stop,
abort, optional stop and block delete, home-all (with
[JOINT_0]HOME_SEQUENCE, like halui), home and unhome of each joint, and
start/stop/forward/reverse/increase/decrease/brake of each spindle. Like
halui's they act on the rising edge, spindle increase and decrease also
on the falling one, and send the same commands.

halui's mode.manual, .auto and .mdi pins are left out: task's modes are
to follow what task runs rather than be set. program.run switches to
Auto first, as halui does.

The commands do not go through NML. emcTaskQueueInternalCommand() queues
them, and the main loop hands one to emcTaskPlan() on each cycle without
a new NML command. They leave the echo serial number alone, and a
refused one is reported on the error channel only: it does not turn the
status of the UI's last command into ERROR, nor does a successful one
clear that command's error.

tests/task-hal-inputs pulses each pin, without halui, and checks both;
it also sets one of the pins from a HAL file.
Three halui pins have a counterpart in iocontrol that is not quite the
same signal, so a configuration could not just be renamed to it:

- task.estop.is-activated: iocontrol.0.user-enable-out is its inverse.
- task.estop.activate: iocontrol.0.emc-enable-in is a level that holds
  the machine in E-stop; this is an edge that puts it there once.
- task.tool.number: iocontrol.0.tool-number is signed, halui's unsigned.

With these, each halui pin that motion, iocontrol or task now covers has
exactly one pin to be renamed to.
task-hal-inputs and task-hal-pins ran the same configuration but for
halui and the homing sequence. They are one test now: the input pins
first, without halui, then halui is loaded and the status pins are
compared with its own.

An input pin is held until task has acted on it, and then low until
task has run two more cycles, instead of a 50 ms pulse that a loaded
machine could let fall between two task cycles. The refused
program.step waits for the refusal on the error channel instead of
200 ms, so the status it checks is the one after task handled it.
milltask(1) lists the task.* pins, says that an input pin command does
not take the place of a user interface's command but that the status
still shows a run it starts, and that task.estop.activate is not a
safety input: it is an edge task handles in its next cycle, and the
E-stop chain belongs on iocontrol.0.emc-enable-in.
Axes can be jogged (keyboard, AXIS, halui, linuxcncrsh, wheel) while a
program or MDI command is paused, M0/M1 included, once the pause has
stopped the motion. Joints cannot.

Motion keeps the paused program position and adds a per-axis pause
offset on top of it, as the external offsets are added (axis_pause_*()
in axis.c), within the soft limits. The queued moves and the interpreter
are untouched. On resume or step, do_pause_resume() (control.c):

- puts the spindles back as they were at the pause (state, direction,
  speed, CSS) and waits for them to be at speed;
- returns the axes: the ones not in [TRAJ]PAUSE_RETURN_LAST (default Z)
  together in a straight line, then those, at the axis limits, and sets
  the offsets to exactly zero;
- then resumes or steps.

Task restores mist and flood. Pausing during the return stops it there.
An abort keeps the machine where it was jogged to: the planner takes the
offsets into its position. Reverse run is refused while jogged away.

Status: pause_offset, pause_jog_ok and pause_returning in EMC_MOTION_STAT
and Python. Task accepts axis jogs while paused (planSpecial()), halui
and linuxcncrsh send them, AXIS enables its jog and spindle controls (not
homing) and does not ask for Manual mode while paused.

This is the work from LinuxCNC#4700, for a task that still has modes:

- the mode stays Auto or MDI during the pause; nothing switches it;
- in coordinated mode without a pause (MDI mode, idle) a jog still does
  nothing and reports nothing;
- no absolute jog, which this branch has removed.

Tests: new tests/jog-while-paused; motion-logger expectations gain the
SET_PAUSE_RETURN_LAST startup command.
GStat gets is_jog_ok(), is_spindle_ok(), is_pause_jog_ok() and a
pause-jog-ok-changed signal. Jog and spindle action buttons use them,
STOP_JOG works while paused, and UPDATE_VAR_FILE saves the parameter
file with task_plan_synch() instead of a mode change.
Show the jog page while jogs during a pause are possible and restore
the previous page on resume or abort.
Don't switch to teleop while paused. Gscreen makes its mode and axis
buttons sensitive while paused and returns to the paused mode on resume.
Use STATUS.is_jog_ok() in kb_jog and only switch to manual mode when
not jogging during a pause.
In position is the planner's. The joints follow it through the cubic
interpolators and arrive a few cycles later. Since mode changes are
deferred instead of dropped, the change to joint mode happened on the
first in-position cycle and took pos_cmd mid-spline, so an MDI move from
joint mode ended up to 0.0003 mm off its target in about 1 run in 100.

Wait until the last four points of each joint's cubic are the same. A
moving external offset never rests, so it does not hold the change up.
Manual, MDI and Auto are no longer modes a user interface switches
between. Task tracks what it runs (idle, a program, MDI) and reports the
mode from that: Auto while a program runs or is paused, MDI while MDI
commands run, Manual otherwise.

- While idle task accepts jogs, homing, MDI commands and program runs.
  Starting a run checks homing, an open program and that no jog
  (including a wheel jog) is active, switches motion to coordinated mode
  and re-syncs the interpreter; nothing leaves interp_list until motion
  is in coordinated mode. When the run ends motion goes back to the joint
  or world mode it had before, so wheel jogs work whenever nothing runs.
- The planner chooses its command table by what runs: idle (the old
  Manual and Auto-idle tables merged), program (unchanged), MDI running
  (jogs and joint/world switching refused).
- An MDI command from idle starts an MDI run and then is issued or
  queued as one sent while MDI runs: it waits for what an abort routine
  still has in interp_list, a kinematics switch included, so it is not
  read under the kinematics the switch is leaving.
- EMC_TASK_SET_MODE is accepted in any state and does nothing.
- halui: halui.mode.manual, .mdi and .auto do nothing, the is-* pins show
  the derived mode, MDI commands go straight to task.

User interfaces that switch pages on the mode keep working through a
per-UI view mode: Python mode(), Tcl emc_mode and linuxcncrsh set mode
(per connection) record the page asked for, and task_mode / get mode
report it while task is idle. AXIS loses its "coordinated while Manual,
force teleop" kick and the dead tab-raise code.

Behaviour changes, documented in updating-linuxcnc: switching to Manual
no longer aborts a running MDI command; a run started from Manual runs
the program; a run with no program open is refused; the parameter file
is saved at the start of every MDI command from idle.

Tests: new tests/task-modeless; halui/mdi rewritten, task-hal expects
Manual after MDI commands for the new
semantics; g28.2/invalid-pword waits for motion to leave coordinated
mode; motion-logger, M99, interp_initcode and linuxcncrsh expectations
updated for the mode switches that moved (COORD at run start, FREE or
TELEOP at run end, no abort from a mode change).
mode() sends nothing to task any more; it sets the page the user
interface shows. The wait_complete() after it waited on whatever command
came before, and while a program runs or is paused task does not report
DONE, so each one sat out its timeout: AXIS hung for 5 s on a spindle
button while paused (ensure_mode()).

Remove the wait after every mode() call in the user interfaces, their
libraries and the sample configs: AXIS, gmoccapy, gscreen and the
silverdragon skin, touchy, pyui, GStat, the gladevcp and qtvcp actions,
the gladevcp offset page and probe panels, the 3pcenter panel. The waits
after teleop_enable() that follow some of them stay.
When the last MDI command finished, task reported DONE in the cycle
before the run ended, and again before motion was back in joint or
world mode. A client waiting for DONE could then see coordinated mode,
or have an axis jog refused: linuxcncrsh's test read TELEOP_ENABLE OFF
after its MDI commands on CI.

Task now reports DONE only when no run is on and motion is in the mode
the run went back to (with a 1 s timeout should motion not get there).

tests/task-modeless checks that motion is in world mode as soon as an
MDI command is DONE, and that a jog right after is accepted.
stale-motion-status no longer waits for coordinated mode after
mode(AUTO), and jog-while-paused reads task.mode.is-manual.
The save was dropped by looking at task_paused, which a program that ends
normally leaves set: after stepping a program to its end, a paused MDI
command would have resumed with that program's coolant. taskRunEnd()
clears it, as on the modeless branches.
The task mode follows what task runs, and nothing sets it any more:
task accepted EMC_TASK_SET_MODE and did nothing, and the Python, Tcl and
linuxcncrsh mode commands stopped sending it.

- NML: drop EMC_TASK_SET_MODE (type 504) and task's handling of it.
- shcom: drop sendManual(), sendAuto() and sendMdi(); schedrmt and
  emclcd no longer switch modes before MDI or opening a program, and
  emclcd's Test key no longer toggles the mode.
- halui: drop halui.mode.manual, .auto and .mdi. The .is-* status pins
  stay.
- Users of the pins: the xhc-hb04 pendant helper starts a program with
  halui.program.run only, the halui_pyvcp sim panel keeps the mode LEDs,
  the xhc-whb04b-6 example configuration and docs drop their mode nets,
  the remote start example needs halui.program.run only.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants