Skip to content

task: halui's pins in task (task.*) - #4970

Open
rene-dev wants to merge 15 commits into
LinuxCNC:masterfrom
rene-dev:task-halui-pins
Open

rene-dev wants to merge 15 commits into
LinuxCNC:masterfrom
rene-dev:task-halui-pins

Conversation

@rene-dev

@rene-dev rene-dev commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

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.. This is the first step towards removing halui; overrides, MDI commands, jogging and joint/axis selection follow later. halui is untouched here and keeps working.

Builds on #4969 (the planner refactor): the first 10 commits are that PR. This PR's own commits are the last 5.

Commits

  1. task: export halui's status pins that motion and iocontrol lack
    The task component and its status pins (tables below). 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. task.tool.diameter reads the loaded tool's entry from the status, as halui does. The component is created before inihal is ready, because the linuxcnc script runs the HAL files as soon as it is, so HAL files can connect task.* pins as they can halui's.
  2. 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() in a 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 a UI's last command.
  3. 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.
  4. tests: task-hal, one test for task's input and status pins
    One configuration: first each input pin is driven without halui and its effect checked, including that a refused one leaves the UI's command status alone and a successful one doesn't clear its error. Then halui is loaded and every status pin is compared with halui's in Manual, teleop, MDI with offsets and tools, with overrides, and while a program runs and is paused. An input is held until task has acted on it, then low until task has run two more cycles (stat.taskbeat), so a loaded machine can't miss it.
  5. docs: task's HAL pins
    milltask(1) lists the pins, and says that task.estop.activate is not a safety input.

Difference from halui

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

A command from a pin has no serial number of its own. With halui, the NML command it sent was newer than a GUI's last one, so a GUI's wait_complete() returned DONE as soon as halui sent anything. With task's pins, the status keeps echoing the GUI's command, and shows EXEC while a program started from a pin runs. A GUI that calls wait_complete() during that run waits for it. That's what happens today when the GUI waits on a command sent while another client's program runs, so the difference is only in the window where the pin starts a run while the GUI's own command is still in progress. The man page says so.

task.estop.activate, like halui.estop.activate, is an edge handled in task's next cycle, after whatever is already queued. It is not a safety input and doesn't replace iocontrol.0.emc-enable-in; the man page says that too.

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)

Part of #4832, which stays open as the tracking branch.

@BsAtHome

BsAtHome commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

You use the old HAL terminology which got scrapped and replaced. You should move to the new naming convention. And, fwiw, 32-bit s32/u32 do no longer exist, at all.

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.
@rene-dev

rene-dev commented Dec 6, 2026

Copy link
Copy Markdown
Member Author

Thanks, fixed. The task.* pins in milltask(1) now use bool, real and uint, and the pin tables in the description use bool, real, uint and sint (iocontrol.0.tool-number is sint). The code already used hal_pin_new_bool/real/uint. The fix is in the docs commit here and in the stacked PRs; all of them are rebased on master.

@rene-dev
rene-dev marked this pull request as ready for review December 6, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants