Browse Source

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

Ketil Froyn 12 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
 // M908 - Control digital trimpot directly.
132
 // M908 - Control digital trimpot directly.
133
 // M350 - Set microstepping mode.
133
 // M350 - Set microstepping mode.
134
 // M351 - Toggle MS1 MS2 pins directly.
134
 // M351 - Toggle MS1 MS2 pins directly.
135
+// M928 - Start SD logging (M928 filename.g) - ended by M29
135
 // M999 - Restart after being stopped by error
136
 // M999 - Restart after being stopped by error
136
 
137
 
137
 //Stepper Movement Variables
138
 //Stepper Movement Variables
394
 	if(strstr_P(cmdbuffer[bufindr], PSTR("M29")) == NULL)
395
 	if(strstr_P(cmdbuffer[bufindr], PSTR("M29")) == NULL)
395
 	{
396
 	{
396
 	  card.write_command(cmdbuffer[bufindr]);
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
 	else
407
 	else
400
 	{
408
 	{
949
 	 card.removeFile(strchr_pointer + 4);
957
 	 card.removeFile(strchr_pointer + 4);
950
 	}
958
 	}
951
 	break;
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
 #endif //SDSUPPORT
970
 #endif //SDSUPPORT
954
 
971
 

+ 7
- 0
Marlin/cardreader.cpp View File

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

Loading…
Cancel
Save