Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/emc/task/emctask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
********************************************************************/

#include <stdlib.h>
#include <math.h> // fabs()
#include <rtapi_string.h> // rtapi_strlcpy()
#include <sys/stat.h> // struct stat
#include <unistd.h> // stat()
Expand Down Expand Up @@ -548,6 +549,17 @@ int emcTaskPlanOpen(const char *file)
emcStatus->task.readLine = 0;
}

// Reset canon length units to machine default before re-opening.
// Without this, G20/G21 from the previous run persists in
// canon.lengthUnits, causing FROM_PROG_LEN() to convert differently
// on re-run for G-code commands that appear before G20/G21.
double units = GET_EXTERNAL_LENGTH_UNITS();
if (fabs(units - 1.0 / 25.4) < 1.0e-3) {
USE_LENGTH_UNITS(CANON_UNITS_INCHES);
} else if (fabs(units - 1.0) < 1.0e-3) {
USE_LENGTH_UNITS(CANON_UNITS_MM);
}

int retval = interp.open(file);
if (retval > INTERP_MIN_ERROR) {
print_interp_error(retval);
Expand Down
Loading