Skip to content
Open
Show file tree
Hide file tree
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
16 changes: 10 additions & 6 deletions src/emc/rs274ngc/interp_convert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2850,7 +2850,8 @@ int Interp::convert_length_units(int g_code, //!< g_code being executed (mus
int Interp::gen_settings(
int *int_current, int *int_saved, // G-codes
double *float_current, double *float_saved, // S, F, other
std::string &cmd) // command buffer
std::string &cmd, // command buffer
bool include_spindle_speed)
{
FORCE_LC_NUMERIC_C;
int i, val;
Expand All @@ -2871,8 +2872,11 @@ int Interp::gen_settings(
cmd += buf;
break;
case GM_FIELD_FLOAT_SPEED:
snprintf(buf,sizeof(buf)," S%.0f", float_saved[i]);
cmd += buf;
// No S word on abort restore: the spindle was just stopped
if (include_spindle_speed) {
snprintf(buf,sizeof(buf)," S%.0f", float_saved[i]);
cmd += buf;
}
break;
case GM_FIELD_FLOAT_PATH_TOLERANCE:
case GM_FIELD_FLOAT_NAIVE_CAM_TOLERANCE:
Expand Down Expand Up @@ -3061,13 +3065,13 @@ int Interp::gen_restore_cmd(int *current_g,
cmd.c_str());
}

// M codes and spindle speed should not be restored during an abort
if ((res = gen_settings(
current_g, saved_g, current_settings, saved_settings, cmd))) {
current_g, saved_g, current_settings, saved_settings, cmd, false))) {
logStateTags("gen_restore_cmd(): error restoring settings (%d)",
res);
return INTERP_ERROR;
}
// M codes should not be restored during an abort with gen_m_codes()

return INTERP_OK;
}
Expand Down Expand Up @@ -3135,7 +3139,7 @@ int Interp::restore_settings(setup_pointer settings,
(int *)settings->sub_context[from_level].saved_g_codes,
(double *)settings->active_settings,
(double *)settings->sub_context[from_level].saved_settings,
cmd);
cmd, true);
gen_m_codes(
(int *) settings->active_m_codes,
(int *)settings->sub_context[from_level].saved_m_codes,
Expand Down
3 changes: 2 additions & 1 deletion src/emc/rs274ngc/rs274ngc_interp.hh
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,8 @@ int read_dollar(char *line, int *counter, block_pointer block,
int gen_settings(
int *int_current, int *int_saved,
double *float_current, double *float_saved,
std::string &cmd);
std::string &cmd,
bool include_spindle_speed);
int gen_m_codes(int *current, int *saved, std::string &cmd);
int gen_restore_cmd(int *current_g,
int *current_m,
Expand Down