M503 implemented. Prints the config file to USB.
This commit is contained in:
parent
926aabe078
commit
ec5f5fe536
3 changed files with 49 additions and 2 deletions
43
GCodes.cpp
43
GCodes.cpp
|
@ -60,6 +60,7 @@ void GCodes::Init()
|
|||
fileBeingPrinted = NULL;
|
||||
fileToPrint = NULL;
|
||||
fileBeingWritten = NULL;
|
||||
configFile = NULL;
|
||||
homeX = false;
|
||||
homeY = false;
|
||||
homeZ = false;
|
||||
|
@ -581,6 +582,44 @@ void GCodes::RunConfigurationGCodes()
|
|||
fileToPrint = NULL;
|
||||
}
|
||||
|
||||
bool GCodes::SendConfigToLine()
|
||||
{
|
||||
if(configFile == NULL)
|
||||
{
|
||||
configFile = platform->GetFileStore(platform->GetSysDir(), platform->GetConfigFile(), false);
|
||||
if(configFile == NULL)
|
||||
{
|
||||
platform->Message(HOST_MESSAGE, "Configuration file not found\n");
|
||||
return true;
|
||||
}
|
||||
platform->GetLine()->Write('\n');
|
||||
}
|
||||
|
||||
char b;
|
||||
|
||||
while(configFile->Status() & byteAvailable)
|
||||
{
|
||||
if(configFile->Read(b))
|
||||
{
|
||||
platform->GetLine()->Write(b);
|
||||
if(b == '\n')
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
platform->GetLine()->Write('\n');
|
||||
configFile->Close();
|
||||
configFile = NULL;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Should never get here
|
||||
|
||||
configFile->Close();
|
||||
configFile = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Function to handle dwell delays. Return true for
|
||||
// dwell finished, false otherwise.
|
||||
|
@ -1194,6 +1233,10 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
|
|||
case 304: // Set thermistor parameters
|
||||
break;
|
||||
|
||||
case 503: // Print parameters
|
||||
result = SendConfigToLine();
|
||||
break;
|
||||
|
||||
case 550: // Set machine name
|
||||
if(gb->Seen('P'))
|
||||
reprap.GetWebserver()->SetName(gb->GetString());
|
||||
|
|
2
GCodes.h
2
GCodes.h
|
@ -100,6 +100,7 @@ class GCodes
|
|||
void HandleReply(bool error, bool fromLine, char* reply, char gMOrT, int code, bool resend);
|
||||
char* OpenFileToWrite(char* fileName, GCodeBuffer *gb);
|
||||
void WriteGCodeToFile(GCodeBuffer *gb);
|
||||
bool SendConfigToLine();
|
||||
|
||||
int8_t Heater(int8_t head);
|
||||
Platform* platform;
|
||||
|
@ -125,6 +126,7 @@ class GCodes
|
|||
FileStore* fileBeingPrinted;
|
||||
FileStore* fileToPrint;
|
||||
FileStore* fileBeingWritten;
|
||||
FileStore* configFile;
|
||||
int8_t selectedHead;
|
||||
bool homeX;
|
||||
bool homeY;
|
||||
|
|
|
@ -622,6 +622,7 @@ bool FileStore::Open(char* directory, char* fileName, bool write)
|
|||
snprintf(scratchString, STRING_LENGTH, "%d", openReturn);
|
||||
platform->Message(HOST_MESSAGE, scratchString);
|
||||
platform->Message(HOST_MESSAGE, "\n");
|
||||
Close();
|
||||
return false;
|
||||
}
|
||||
bufferPointer = 0;
|
||||
|
@ -636,9 +637,10 @@ bool FileStore::Open(char* directory, char* fileName, bool write)
|
|||
snprintf(scratchString, STRING_LENGTH, "%d", openReturn);
|
||||
platform->Message(HOST_MESSAGE, scratchString);
|
||||
platform->Message(HOST_MESSAGE, "\n");
|
||||
Close();
|
||||
return false;
|
||||
}
|
||||
bufferPointer = FILE_BUF_LEN;
|
||||
} else
|
||||
ReadBuffer();
|
||||
}
|
||||
|
||||
inUse = true;
|
||||
|
|
Reference in a new issue