Workaround for skipping large comment blocks
If there are large blocks of comments in the G-code, the printer may get shot down by its own watchdog. Watchdog is generally set to 4s and updated only in manage_heaters (and some other spots in some specific cases). So far, the code reading the file and feeding it into Marlin cycles indefinitely until it finds valid G-code lines and fills up the command queue. If the block is large enough, the printer cannot read it completely within those 4s. A simple workaround - bail out after some consecutive empty/comment lines to enable other parts of code do their job (especially manage_heaters). Tested on MK404, previous FW fails with 600KB of comment lines at the beginning, this patch survives. The printer even draws some update on its status screen before starting a real print.
This commit is contained in:
parent
c28e5a9dbc
commit
dcc6605809
@ -573,6 +573,7 @@ void get_command()
|
|||||||
// this character _can_ occur in serial com, due to checksums. however, no checksums are used in SD printing
|
// this character _can_ occur in serial com, due to checksums. however, no checksums are used in SD printing
|
||||||
|
|
||||||
static bool stop_buffering=false;
|
static bool stop_buffering=false;
|
||||||
|
static uint8_t consecutiveEmptyLines = 0;
|
||||||
if(buflen==0) stop_buffering=false;
|
if(buflen==0) stop_buffering=false;
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
@ -586,11 +587,12 @@ void get_command()
|
|||||||
while( !card.eof() && !stop_buffering) {
|
while( !card.eof() && !stop_buffering) {
|
||||||
int16_t n=card.get();
|
int16_t n=card.get();
|
||||||
char serial_char = (char)n;
|
char serial_char = (char)n;
|
||||||
if(serial_char == '\n' ||
|
if( serial_char == '\n'
|
||||||
serial_char == '\r' ||
|
|| serial_char == '\r'
|
||||||
((serial_char == '#' || serial_char == ':') && comment_mode == false) ||
|
|| ((serial_char == '#' || serial_char == ':') && comment_mode == false)
|
||||||
serial_count >= (MAX_CMD_SIZE - 1) || n==-1)
|
|| serial_count >= (MAX_CMD_SIZE - 1)
|
||||||
{
|
|| n==-1
|
||||||
|
){
|
||||||
if(serial_char=='#')
|
if(serial_char=='#')
|
||||||
stop_buffering=true;
|
stop_buffering=true;
|
||||||
|
|
||||||
@ -602,6 +604,10 @@ void get_command()
|
|||||||
// so that the lenght of the already read empty lines and comments will be added
|
// so that the lenght of the already read empty lines and comments will be added
|
||||||
// to the following non-empty line.
|
// to the following non-empty line.
|
||||||
comment_mode = false;
|
comment_mode = false;
|
||||||
|
if( ++consecutiveEmptyLines > 250 ){
|
||||||
|
consecutiveEmptyLines = 0;
|
||||||
|
return; // prevent cycling indefinitely - let manage_heaters do their job
|
||||||
|
}
|
||||||
continue; //if empty line
|
continue; //if empty line
|
||||||
}
|
}
|
||||||
// The new command buffer could be updated non-atomically, because it is not yet considered
|
// The new command buffer could be updated non-atomically, because it is not yet considered
|
||||||
@ -638,6 +644,7 @@ void get_command()
|
|||||||
|
|
||||||
comment_mode = false; //for new command
|
comment_mode = false; //for new command
|
||||||
serial_count = 0; //clear buffer
|
serial_count = 0; //clear buffer
|
||||||
|
consecutiveEmptyLines = 0; // reached a non-empty line which shall be enqueued
|
||||||
|
|
||||||
if(card.eof()) break;
|
if(card.eof()) break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user