Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Run from here" reloads the gcode file but doesn't update the display #2418

Closed
1 of 3 tasks
jes opened this issue Apr 1, 2023 · 2 comments
Closed
1 of 3 tasks

"Run from here" reloads the gcode file but doesn't update the display #2418

jes opened this issue Apr 1, 2023 · 2 comments

Comments

@jes
Copy link
Contributor

jes commented Apr 1, 2023

Here are the steps I follow to reproduce the issue:

  1. Start a job
  2. Edit the coordinates in the gcode file (e.g. add 100 to all the Y values) but do not reload the file in the Axis gui
  3. Hit the emergency stop
  4. Take the machine out of emergency stop
  5. Use "run from here" to resume your job
  6. The machine cuts the updated coordinates in the gcode file, even though the old coordinates are still shown in the gcode display

This is what I expected to happen:

I expected the machine to continue with the coordinates shown in the gcode display (i.e. the line of gcode that I actually clicked "run from here" on).

This is what happened instead:

The machine rapid'd over 100mm and broke my tool.

Information about my hardware and software:

  • I am using this Linux distribution and version (often, shown by lsb_release -a): Debian 10 buster
  • I am using this kernel version (shown by uname -a): Linux linuxcnc 4.19.0-17-rt-amd64 #1 SMP PREEMPT RT Debian 4.19.194-2 (2021-06-21) x86_64 GNU/Linux
  • I am running ...
    • A binary version from linuxcnc.org (including buildbot.linuxcnc.org)
    • A binary I built myself
    • A binary version from some other source besides linuxcnc.org
  • I am using this LinuxCNC version (shown in package manager or, for git versions, scripts/get-version-from-git): 1:2.8.2.11.g6a3d0a434
  • I am using this user interface (GUI) (e.g., AXIS, Touchy, gmoccapy, etc): AXIS
  • I am using this interface hardware vendor and chipset (e.g., parallel port, ethernet port, FPGA card): Parallel port
@jes
Copy link
Contributor Author

jes commented Apr 1, 2023

I've had a look through the AXIS source and I think the bug is not specifically in AXIS, but in the way AXIS and LinuxCNC communicate with each other.

When you load a file in AXIS, it loads the file itself to provide the gcode view, and it also asks LinuxCNC to load the same file (small race window there, but that's not the big issue).

The big issue is that LinuxCNC doesn't actually buffer the file in memory at all! As far as I can tell it just open()'s the file and awaits further instruction. So if you change the file on disk before you execute something, LinuxCNC will use the updated file but AXIS won't know to refresh the gcode shown in the user interface.

I'm not sure why this problem only manifested itself after I used "run from line", instead of as soon as I saved the updated file. I'm guessing LinuxCNC had buffered the rest of the file contents (maybe because of the motion planner looking ahead? I don't know). But this seems pretty dangerous generally.

Maybe AXIS should check periodically to see if the mtime has changed, and if so put up a big warning and maybe pause the job? The existing behaviour is very unintuitive to anyone who doesn't already know that AXIS and LinuxCNC are so loosely coupled.

(Edit:) Or maybe AXIS should simply copy your gcode file to a temporary directory, and give LinuxCNC the path to the copy (similar to what it does if you're using a "filter") so that if you change the original on disk, then at least LinuxCNC still has its copy of the original. I think that's probably better than checking mtime and giving a warning.

jes added a commit to jes/linuxcnc that referenced this issue Apr 1, 2023
The issue here is that if you open a gcode file, and then change the
file on disk, you'll think your changes are completely inert because
they don't show up in the GUI, but actually LinuxCNC has its own
separate file handle behind-the-scenes, and your machine can do scary
and unpredictable things.

With this fix, the code being executed by LinuxCNC always matches what
is displayed in the AXIS GUI even if you subsequently change the file.
andypugh added a commit that referenced this issue Apr 10, 2023
axis: copy gcode to temporary file before opening (fixes #2418)
@rmu75
Copy link
Contributor

rmu75 commented Oct 31, 2023

Unfortunately the merged fix for this causes problems and isn't a real solution in the first place (there are other GUIs than axis). #2490

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

No branches or pull requests

2 participants