Skip to content

Commit

Permalink
Merge pull request MarlinFirmware#425 from kefir-/m928_logging
Browse files Browse the repository at this point in the history
M928 logging
  • Loading branch information
ErikZalm committed Mar 30, 2013
2 parents 8686792 + f036be7 commit 7f62246
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
19 changes: 18 additions & 1 deletion Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
// M908 - Control digital trimpot directly.
// M350 - Set microstepping mode.
// M351 - Toggle MS1 MS2 pins directly.
// M928 - Start SD logging (M928 filename.g) - ended by M29
// M999 - Restart after being stopped by error

//Stepper Movement Variables
Expand Down Expand Up @@ -403,7 +404,14 @@ void loop()
if(strstr_P(cmdbuffer[bufindr], PSTR("M29")) == NULL)
{
card.write_command(cmdbuffer[bufindr]);
SERIAL_PROTOCOLLNPGM(MSG_OK);
if(card.logging)
{
process_commands();
}
else
{
SERIAL_PROTOCOLLNPGM(MSG_OK);
}
}
else
{
Expand Down Expand Up @@ -958,6 +966,15 @@ void process_commands()
card.removeFile(strchr_pointer + 4);
}
break;
case 928: //M928 - Start SD write
starpos = (strchr(strchr_pointer + 5,'*'));
if(starpos != NULL){
char* npos = strchr(cmdbuffer[bufindr], 'N');
strchr_pointer = strchr(npos,' ') + 1;
*(starpos-1) = '\0';
}
card.openLogFile(strchr_pointer+5);
break;

#endif //SDSUPPORT

Expand Down
7 changes: 7 additions & 0 deletions Marlin/cardreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CardReader::CardReader()
sdprinting = false;
cardOK = false;
saving = false;
logging = false;
autostart_atmillis=0;

autostart_stilltocheck=true; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
Expand Down Expand Up @@ -212,6 +213,11 @@ void CardReader::pauseSDPrint()
}


void CardReader::openLogFile(char* name)
{
logging = true;
openFile(name, false);
}

void CardReader::openFile(char* name,bool read)
{
Expand Down Expand Up @@ -471,6 +477,7 @@ void CardReader::closefile()
file.sync();
file.close();
saving = false;
logging = false;
}

void CardReader::getfilename(const uint8_t nr)
Expand Down

0 comments on commit 7f62246

Please sign in to comment.