Browse Source

Add command M928 to enable logging to file of received gcode commands

Ketil Froyn 11 years ago
parent
commit
07e11c7cf5
2 changed files with 25 additions and 1 deletions
  1. 18
    1
      Marlin/Marlin_main.cpp
  2. 7
    0
      Marlin/cardreader.cpp

+ 18
- 1
Marlin/Marlin_main.cpp View File

@@ -132,6 +132,7 @@
132 132
 // M908 - Control digital trimpot directly.
133 133
 // M350 - Set microstepping mode.
134 134
 // M351 - Toggle MS1 MS2 pins directly.
135
+// M928 - Start SD logging (M928 filename.g) - ended by M29
135 136
 // M999 - Restart after being stopped by error
136 137
 
137 138
 //Stepper Movement Variables
@@ -394,7 +395,14 @@ void loop()
394 395
 	if(strstr_P(cmdbuffer[bufindr], PSTR("M29")) == NULL)
395 396
 	{
396 397
 	  card.write_command(cmdbuffer[bufindr]);
397
-	  SERIAL_PROTOCOLLNPGM(MSG_OK);
398
+          if(card.logging)
399
+          {
400
+	    process_commands();
401
+          }
402
+          else
403
+          {
404
+	    SERIAL_PROTOCOLLNPGM(MSG_OK);
405
+          }
398 406
 	}
399 407
 	else
400 408
 	{
@@ -949,6 +957,15 @@ void process_commands()
949 957
 	 card.removeFile(strchr_pointer + 4);
950 958
 	}
951 959
 	break;
960
+    case 928: //M928 - Start SD write
961
+      starpos = (strchr(strchr_pointer + 5,'*'));
962
+      if(starpos != NULL){
963
+        char* npos = strchr(cmdbuffer[bufindr], 'N');
964
+        strchr_pointer = strchr(npos,' ') + 1;
965
+        *(starpos-1) = '\0';
966
+      }
967
+      card.openLogFile(strchr_pointer+5);
968
+      break;
952 969
 	
953 970
 #endif //SDSUPPORT
954 971
 

+ 7
- 0
Marlin/cardreader.cpp View File

@@ -16,6 +16,7 @@ CardReader::CardReader()
16 16
    sdprinting = false;
17 17
    cardOK = false;
18 18
    saving = false;
19
+   logging = false;
19 20
    autostart_atmillis=0;
20 21
 
21 22
    autostart_stilltocheck=true; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
@@ -212,6 +213,11 @@ void CardReader::pauseSDPrint()
212 213
 }
213 214
 
214 215
 
216
+void CardReader::openLogFile(char* name)
217
+{
218
+  logging = true;
219
+  openFile(name, false);
220
+}
215 221
 
216 222
 void CardReader::openFile(char* name,bool read)
217 223
 {
@@ -471,6 +477,7 @@ void CardReader::closefile()
471 477
   file.sync();
472 478
   file.close();
473 479
   saving = false; 
480
+  logging = false;
474 481
 }
475 482
 
476 483
 void CardReader::getfilename(const uint8_t nr)

Loading…
Cancel
Save