Skip to content

docs: say when on_abort is called and with which reason - #4875

Merged
andypugh merged 1 commit into
LinuxCNC:2.9from
grandixximo:on-abort-reasons-doc
Nov 22, 2026
Merged

andypugh merged 1 commit into
LinuxCNC:2.9from
grandixximo:on-abort-reasons-doc

Conversation

@grandixximo

Copy link
Copy Markdown
Contributor

The example on_abort sub in the remap chapter labels reason 5 "machine on", 6 "machine off" and 7 "estopped". Task sends 5 on E-stop reset (the machine is still off), 6 on an E-stop request, and 7 when the machine is no longer on. Turning the machine on calls nothing.

The chapter also does not say when on_abort is called. OFF and E-stop requests call it even when the machine is already off or in E-stop, which is how a GUI triggers it at startup (#4874); a machine that was on gets a second call with reason 7; an error that stops a program or MDI leaves the machine on and brings no 7. I added that, gave each branch of the example a comment saying what the reason means, and added a short second example that skips 4, 5 and 6 and still cleans up when the machine goes off.

I checked every reason with a sim config whose on_abort prints #1, driven from a script, and ran both examples from the page as written:

  • E-stop reset: 5
  • E-stop or OFF while already in E-stop: 6 or 4
  • OFF, E-stop, HAL estop chain opened, while on: 4, 6 or 2, then 7
  • joint amp fault while on: 3, then 7
  • motion.enable dropped while on: 7
  • G38.2 without contact or with the probe already tripped: 3, machine stays on
  • interpreter execution error: 9 in a program, 10 in MDI
  • Esc during a program: 8

Fixes #4874

The example on_abort sub labelled reason 5 "machine on", 6 "machine off" and 7 "estopped". Task sends 5 on E-stop reset, 6 on an E-stop request and 7 when the machine is no longer on.

Say that OFF and E-stop requests call on_abort even when the machine is already off or in E-stop, that a machine which was on gets a second call with reason 7, and which reasons an error that stops a program or MDI gives. The example now has a branch per reason saying what it means, and a second example shows a sub that skips the state requests and still cleans up when the machine goes off.

Fixes LinuxCNC#4874
@andypugh
andypugh merged commit 4dbef2d into LinuxCNC:2.9 Nov 22, 2026
14 checks passed
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