diff --git a/src/emc/rs274ngc/interp_convert.cc b/src/emc/rs274ngc/interp_convert.cc index f01a359652d..9a42be3769e 100644 --- a/src/emc/rs274ngc/interp_convert.cc +++ b/src/emc/rs274ngc/interp_convert.cc @@ -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; @@ -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: @@ -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; } @@ -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, diff --git a/src/emc/rs274ngc/rs274ngc_interp.hh b/src/emc/rs274ngc/rs274ngc_interp.hh index 4165ea8cfd5..05055260604 100644 --- a/src/emc/rs274ngc/rs274ngc_interp.hh +++ b/src/emc/rs274ngc/rs274ngc_interp.hh @@ -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,