Browse Source

Attempt to resolve #1568 and add basic escape character support

C-o-r-E 10 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
     serial_char = MYSERIAL.read();
730
     serial_char = MYSERIAL.read();
731
     if(serial_char == '\n' ||
731
     if(serial_char == '\n' ||
732
        serial_char == '\r' ||
732
        serial_char == '\r' ||
733
-       (serial_char == ':' && comment_mode == false) ||
734
        serial_count >= (MAX_CMD_SIZE - 1) )
733
        serial_count >= (MAX_CMD_SIZE - 1) )
735
     {
734
     {
736
       if(!serial_count) { //if empty line
735
       if(!serial_count) { //if empty line
739
       }
738
       }
740
       cmdbuffer[bufindw][serial_count] = 0; //terminate string
739
       cmdbuffer[bufindw][serial_count] = 0; //terminate string
741
       if(!comment_mode){
740
       if(!comment_mode){
742
-        comment_mode = false; //for new command
743
         fromsd[bufindw] = false;
741
         fromsd[bufindw] = false;
744
         if(strchr(cmdbuffer[bufindw], 'N') != NULL)
742
         if(strchr(cmdbuffer[bufindw], 'N') != NULL)
745
         {
743
         {
823
       }
821
       }
824
       serial_count = 0; //clear buffer
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
   #ifdef SDSUPPORT
839
   #ifdef SDSUPPORT

Loading…
Cancel
Save