this->reply_stream = nullptr;
this->halted= false;
this->suspended= false;
+ this->suspend_loops= 0;
}
void Player::on_module_loaded()
void Player::on_main_loop(void *argument)
{
+ if(suspended && suspend_loops > 0) {
+ // if we are suspended we need to allow main loop to cycle a few times then finsih off the supend processing
+ if(--suspend_loops == 0) {
+ suspend_part2();
+ return;
+ }
+ }
+
if( !this->booted ) {
this->booted = true;
if( this->on_boot_gcode_enable ) {
/**
Suspend a print in progress
1. send pause to upstream host, or pause if printing from sd
+1a. loop on_main_loop several times to clear any buffered commmands
2. wait for empty queue
3. save the current position, extruder position, temperatures - any state that would need to be restored
4. retract by specifed amount either on command line or in config
this->was_playing_file= false;
}
+ // we need to allow main loop to cycle a few times to clear any buffered commands in the serial streams etc
+ suspend_loops= 10;
+ suspend_stream= stream;
+}
+
+// this completes the suspend
+void Player::suspend_part2()
+{
// wait for queue to empty
THEKERNEL->conveyor->wait_for_empty_queue();
- stream->printf("Saving current state...\n");
+ suspend_stream->printf("Saving current state...\n");
// save current XYZ position
THEKERNEL->robot->get_axis_position(this->saved_position);
THEKERNEL->call_event(ON_CONSOLE_LINE_RECEIVED, &message );
}
- stream->printf("Print Suspended, enter resume to continue printing\n");
+ suspend_stream->printf("Print Suspended, enter resume to continue printing\n");
}
/**
void suspend_command( string parameters, StreamOutput* stream );
void resume_command( string parameters, StreamOutput* stream );
string extract_options(string& args);
+ void suspend_part2();
string filename;
string after_suspend_gcode;
string on_boot_gcode;
StreamOutput* current_stream;
StreamOutput* reply_stream;
+ StreamOutput* suspend_stream;
+
FILE* current_file_handler;
unsigned long file_size, played_cnt;
unsigned long elapsed_secs;
bool saved_inch_mode:1;
bool saved_absolute_mode:1;
bool was_playing_file:1;
+ uint8_t suspend_loops:4;
};
};