Browse Source

Merge pull request #425 from kefir-/m928_logging

M928 logging
ErikZalm 11 years ago
parent
commit
7f622467fc
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

@@ -133,6 +133,7 @@
133 133
 // M908 - Control digital trimpot directly.
134 134
 // M350 - Set microstepping mode.
135 135
 // M351 - Toggle MS1 MS2 pins directly.
136
+// M928 - Start SD logging (M928 filename.g) - ended by M29
136 137
 // M999 - Restart after being stopped by error
137 138
 
138 139
 //Stepper Movement Variables
@@ -403,7 +404,14 @@ void loop()
403 404
 	if(strstr_P(cmdbuffer[bufindr], PSTR("M29")) == NULL)
404 405
 	{
405 406
 	  card.write_command(cmdbuffer[bufindr]);
406
-	  SERIAL_PROTOCOLLNPGM(MSG_OK);
407
+          if(card.logging)
408
+          {
409
+            process_commands();
410
+          }
411
+          else
412
+          {
413
+            SERIAL_PROTOCOLLNPGM(MSG_OK);
414
+          }
407 415
 	}
408 416
 	else
409 417
 	{
@@ -958,6 +966,15 @@ void process_commands()
958 966
 	 card.removeFile(strchr_pointer + 4);
959 967
 	}
960 968
 	break;
969
+    case 928: //M928 - Start SD write
970
+      starpos = (strchr(strchr_pointer + 5,'*'));
971
+      if(starpos != NULL){
972
+        char* npos = strchr(cmdbuffer[bufindr], 'N');
973
+        strchr_pointer = strchr(npos,' ') + 1;
974
+        *(starpos-1) = '\0';
975
+      }
976
+      card.openLogFile(strchr_pointer+5);
977
+      break;
961 978
 	
962 979
 #endif //SDSUPPORT
963 980
 

+ 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