1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-27 13:56:24 +00:00

Added a magic character for sd buffering.

if a '#' is read now the buffer will be emptied before reading ahead.
This is so one can execute files from within gcode files, without messing the buffer with preread characters from the caller file.
# can not occure in sd files imho, because it should only occure within checksums in ther serial communication.
Yes, thats a lame argument. If you have a better idea please tell me. It has to be a character that one can type
on a keyboard manually.
This commit is contained in:
bkubicek 2013-10-22 09:54:13 +02:00
parent 7fad13a1e2
commit b2cc27e5ea

View File

@ -620,11 +620,20 @@ void get_command()
if(!card.sdprinting || serial_count!=0){
return;
}
while( !card.eof() && buflen < BUFSIZE) {
//'#' stops reading from sd to the buffer prematurely, so procedural macro calls are possible
// if it occures, stop_buffering is triggered and the buffer is ran dry.
// this character _can_ occure in serial com, due to checksums. however, no checksums are used in sd printing
static bool stop_buffering=false;
if(buflen==0) stop_buffering=false;
while( !card.eof() && buflen < BUFSIZE && !stop_buffering) {
int16_t n=card.get();
serial_char = (char)n;
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)
{
@ -644,6 +653,9 @@ void get_command()
card.checkautostart(true);
}
if(serial_char=='#')
stop_buffering=true;
if(!serial_count)
{
comment_mode = false; //for new command