|
@@ -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
|
|
|
|
|
|
static bool stop_buffering=false;
|
|
|
+ static uint8_t consecutiveEmptyLines = 0;
|
|
|
if(buflen==0) stop_buffering=false;
|
|
|
union {
|
|
|
struct {
|
|
@@ -586,11 +587,12 @@ void get_command()
|
|
|
while( !card.eof() && !stop_buffering) {
|
|
|
int16_t n=card.get();
|
|
|
char serial_char = (char)n;
|
|
|
- if(serial_char == '\n' ||
|
|
|
- serial_char == '\r' ||
|
|
|
- ((serial_char == '#' || serial_char == ':') && comment_mode == false) ||
|
|
|
- serial_count >= (MAX_CMD_SIZE - 1) || n==-1)
|
|
|
- {
|
|
|
+ if( serial_char == '\n'
|
|
|
+ || serial_char == '\r'
|
|
|
+ || ((serial_char == '#' || serial_char == ':') && comment_mode == false)
|
|
|
+ || serial_count >= (MAX_CMD_SIZE - 1)
|
|
|
+ || n==-1
|
|
|
+ ){
|
|
|
if(serial_char=='#')
|
|
|
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
|
|
|
// to the following non-empty line.
|
|
|
comment_mode = false;
|
|
|
+ if( ++consecutiveEmptyLines > 250 ){
|
|
|
+ consecutiveEmptyLines = 0;
|
|
|
+ return; // prevent cycling indefinitely - let manage_heaters do their job
|
|
|
+ }
|
|
|
continue; //if empty line
|
|
|
}
|
|
|
// The new command buffer could be updated non-atomically, because it is not yet considered
|
|
@@ -638,9 +644,10 @@ void get_command()
|
|
|
|
|
|
comment_mode = false; //for new command
|
|
|
serial_count = 0; //clear buffer
|
|
|
+ consecutiveEmptyLines = 0; // reached a non-empty line which shall be enqueued
|
|
|
|
|
|
if(card.eof()) break;
|
|
|
-
|
|
|
+
|
|
|
// The following line will reserve buffer space if available.
|
|
|
if (! cmdqueue_could_enqueue_back(MAX_CMD_SIZE-1, true))
|
|
|
return;
|