Browse Source

Attempt to resolve #1568 and add basic escape character support

C-o-r-E 9 years ago
parent
commit
99fb1bc3e8
1 changed files with 13 additions and 6 deletions
  1. 13
    6
      Marlin/Marlin_main.cpp

+ 13
- 6
Marlin/Marlin_main.cpp View File

@@ -730,7 +730,6 @@ void get_command()
730 730
     serial_char = MYSERIAL.read();
731 731
     if(serial_char == '\n' ||
732 732
        serial_char == '\r' ||
733
-       (serial_char == ':' && comment_mode == false) ||
734 733
        serial_count >= (MAX_CMD_SIZE - 1) )
735 734
     {
736 735
       if(!serial_count) { //if empty line
@@ -739,7 +738,6 @@ void get_command()
739 738
       }
740 739
       cmdbuffer[bufindw][serial_count] = 0; //terminate string
741 740
       if(!comment_mode){
742
-        comment_mode = false; //for new command
743 741
         fromsd[bufindw] = false;
744 742
         if(strchr(cmdbuffer[bufindw], 'N') != NULL)
745 743
         {
@@ -823,10 +821,19 @@ void get_command()
823 821
       }
824 822
       serial_count = 0; //clear buffer
825 823
     }
826
-    else
827
-    {
828
-      if(serial_char == ';') comment_mode = true;
829
-      if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
824
+    else if(serial_char == '\\') {  //Handle escapes
825
+       
826
+        if(MYSERIAL.available() > 0  && buflen < BUFSIZE) {
827
+            // if we have one more character, copy it over
828
+            MYSERIAL.read();
829
+            cmdbuffer[bufindw][serial_count++] = serial_char;
830
+        }
831
+
832
+        //otherwise do nothing        
833
+    }
834
+    else { // its not a newline, carriage return or escape char
835
+        if(serial_char == ';') comment_mode = true;
836
+        if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
830 837
     }
831 838
   }
832 839
   #ifdef SDSUPPORT

Loading…
Cancel
Save