Change how "Stopped" is handled internally, do not inhibit motion
Do not inhibit motion when Stopped is set. We actually do need to move to move away the extruder from the bed, and setting Stopped breaks it without adding any sort of security (M* commands, such as M600 could still perform moves and still pass through, while M104 would still set heaters). During a hard error the internal queue is cleared (and sd file closed, if any), so no new "unforeseen" command can be read. Handle "Stopped" instead as a flag to inhibit serial processing and automatically switch to "paused for user" state. While in this state simply drop any input without incrementing the processed gcode line number, behaving as-if the last command was still being processed. This allows "Stopped" to correctly handle a printer-initiated paused state and recover as expected by requesting a resend when resuming.
This commit is contained in:
parent
b3ca70a007
commit
fc10ca3146
4 changed files with 42 additions and 35 deletions
Firmware
|
@ -28,7 +28,6 @@ ShortTimer serialTimeoutTimer;
|
|||
|
||||
long gcode_N = 0;
|
||||
long gcode_LastN = 0;
|
||||
long Stopped_gcode_LastN = 0;
|
||||
|
||||
uint32_t sdpos_atomic = 0;
|
||||
|
||||
|
@ -464,8 +463,6 @@ void get_command()
|
|||
|
||||
// Don't parse N again with code_seen('N')
|
||||
cmdbuffer[bufindw + CMDHDRSIZE] = '$';
|
||||
//if no errors, continue parsing
|
||||
gcode_LastN = gcode_N;
|
||||
}
|
||||
// if we don't receive 'N' but still see '*'
|
||||
if ((cmdbuffer[bufindw + CMDHDRSIZE] != 'N') && (cmdbuffer[bufindw + CMDHDRSIZE] != '$') && (strchr(cmdbuffer+bufindw+CMDHDRSIZE, '*') != NULL))
|
||||
|
@ -478,35 +475,48 @@ void get_command()
|
|||
serial_count = 0;
|
||||
return;
|
||||
}
|
||||
// Handle KILL early, even when Stopped
|
||||
if(strcmp(cmdbuffer+bufindw+CMDHDRSIZE, "M112") == 0)
|
||||
kill(MSG_M112_KILL, 2);
|
||||
// Handle the USB timer
|
||||
if ((strchr_pointer = strchr(cmdbuffer+bufindw+CMDHDRSIZE, 'G')) != NULL) {
|
||||
if (!IS_SD_PRINTING) {
|
||||
usb_timer.start();
|
||||
}
|
||||
if (Stopped == true) {
|
||||
if (code_value_uint8() <= 3) {
|
||||
SERIAL_ERRORLNRPGM(MSG_ERR_STOPPED);
|
||||
LCD_MESSAGERPGM(_T(MSG_STOPPED));
|
||||
}
|
||||
}
|
||||
} // end of 'G' command
|
||||
}
|
||||
if (Stopped == true) {
|
||||
// Stopped can be set either during error states (thermal error: cannot continue), or
|
||||
// when a printer-initiated action is processed. In such case the printer will send to
|
||||
// the host an action, but cannot know if the action has been processed while new
|
||||
// commands are being sent. In this situation we just drop the command while issuing
|
||||
// periodic "busy" messages in the main loop. Since we're not incrementing the received
|
||||
// line number, a request for resend will happen (if necessary), ensuring we don't skip
|
||||
// commands whenever Stopped is cleared and processing resumes.
|
||||
serial_count = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// Command is complete: store the current line into buffer, move to the next line.
|
||||
|
||||
//If command was e-stop process now
|
||||
if(strcmp(cmdbuffer+bufindw+CMDHDRSIZE, "M112") == 0)
|
||||
kill(MSG_M112_KILL, 2);
|
||||
|
||||
// Store the current line into buffer, move to the next line.
|
||||
// Store type of entry
|
||||
cmdbuffer[bufindw] = gcode_N ? CMDBUFFER_CURRENT_TYPE_USB_WITH_LINENR : CMDBUFFER_CURRENT_TYPE_USB;
|
||||
|
||||
#ifdef CMDBUFFER_DEBUG
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPGM("Storing a command line to buffer: ");
|
||||
SERIAL_ECHO(cmdbuffer+bufindw+CMDHDRSIZE);
|
||||
SERIAL_ECHOLNPGM("");
|
||||
#endif /* CMDBUFFER_DEBUG */
|
||||
|
||||
// Store command itself
|
||||
bufindw += strlen(cmdbuffer+bufindw+CMDHDRSIZE) + (1 + CMDHDRSIZE);
|
||||
if (bufindw == sizeof(cmdbuffer))
|
||||
bufindw = 0;
|
||||
++ buflen;
|
||||
|
||||
// Update the processed gcode line
|
||||
gcode_LastN = gcode_N;
|
||||
|
||||
#ifdef CMDBUFFER_DEBUG
|
||||
SERIAL_ECHOPGM("Number of commands in the buffer: ");
|
||||
SERIAL_ECHO(buflen);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue