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.
master
bkubicek 11 years ago
parent 7fad13a1e2
commit b2cc27e5ea

@ -620,11 +620,20 @@ void get_command()
if(!card.sdprinting || serial_count!=0){ if(!card.sdprinting || serial_count!=0){
return; 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(); int16_t n=card.get();
serial_char = (char)n; 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 == ':' && comment_mode == false) ||
serial_count >= (MAX_CMD_SIZE - 1)||n==-1) serial_count >= (MAX_CMD_SIZE - 1)||n==-1)
{ {
@ -644,6 +653,9 @@ void get_command()
card.checkautostart(true); card.checkautostart(true);
} }
if(serial_char=='#')
stop_buffering=true;
if(!serial_count) if(!serial_count)
{ {
comment_mode = false; //for new command comment_mode = false; //for new command

Loading…
Cancel
Save