Browse Source

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.
bkubicek 11 years ago
parent
commit
b2cc27e5ea
1 changed files with 14 additions and 2 deletions
  1. 14
    2
      Marlin/Marlin_main.cpp

+ 14
- 2
Marlin/Marlin_main.cpp View File

@@ -620,11 +620,20 @@ void get_command()
620 620
   if(!card.sdprinting || serial_count!=0){
621 621
     return;
622 622
   }
623
-  while( !card.eof()  && buflen < BUFSIZE) {
623
+  
624
+  //'#' stops reading from sd to the buffer prematurely, so procedural macro calls are possible
625
+  // if it occures, stop_buffering is triggered and the buffer is ran dry. 
626
+  // this character _can_ occure in serial com, due to checksums. however, no checksums are used in sd printing
627
+  
628
+  static bool stop_buffering=false;
629
+  if(buflen==0) stop_buffering=false;
630
+  
631
+  while( !card.eof()  && buflen < BUFSIZE && !stop_buffering) { 
624 632
     int16_t n=card.get();
625
-    serial_char = (char)n;
633
+    serial_char = (char)n; 
626 634
     if(serial_char == '\n' ||
627 635
        serial_char == '\r' ||
636
+       serial_char == '#' ||
628 637
        (serial_char == ':' && comment_mode == false) ||
629 638
        serial_count >= (MAX_CMD_SIZE - 1)||n==-1)
630 639
     {
@@ -644,6 +653,9 @@ void get_command()
644 653
         card.checkautostart(true);
645 654
 
646 655
       }
656
+      if(serial_char=='#')
657
+        stop_buffering=true;
658
+      
647 659
       if(!serial_count)
648 660
       {
649 661
         comment_mode = false; //for new command

Loading…
Cancel
Save