Skip to content
Merged
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
9 changes: 7 additions & 2 deletions src/emc/rs274ngc/interp_convert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5150,16 +5150,21 @@ int Interp::convert_stop(block_pointer block, //!< pointer to a block of RS27
PROGRAM_STOP();
} else if (block->m_modes[4] == 1) {
OPTIONAL_PROGRAM_STOP();
} else if (block->m_modes[4] == 99 && _setup.loop_on_main_m99) {
} else if (block->m_modes[4] == 99 && _setup.loop_on_main_m99 &&
settings->file_pointer != NULL) {

// Fanuc-style M99 main program endless loop
// Only loops when running from a file; in MDI there is no file to
// seek back to, so M99 falls through to the M2/M30 program-end path
// below (avoids a fseek(NULL) segfault).
logDebug("M99 main program endless loop");

loop_to_beginning(settings); // return control to beginning of file
FINISH(); // Output any final linked segments
return INTERP_EXECUTE_FINISH; // tell task to issue any queued commands
} else if ((block->m_modes[4] == 2) || (block->m_modes[4] == 30) ||
(block->m_modes[4] == 99 && !_setup.loop_on_main_m99)
(block->m_modes[4] == 99 &&
(!_setup.loop_on_main_m99 || settings->file_pointer == NULL))
) { /* reset stuff here */

/*1*/
Expand Down
3 changes: 2 additions & 1 deletion src/emc/rs274ngc/interp_o_word.cc
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,8 @@ void Interp::loop_to_beginning(setup_pointer settings)
settings->filename);

// scroll back to beginning of file/first block
fseek(settings->file_pointer, 0, SEEK_SET);
if (settings->file_pointer != NULL)
fseek(settings->file_pointer, 0, SEEK_SET);
settings->sequence_number = 0;
}

Expand Down
Loading