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;
|
fileBeingPrinted = NULL;
|
||||||
fileToPrint = NULL;
|
fileToPrint = NULL;
|
||||||
fileBeingWritten = NULL;
|
fileBeingWritten = NULL;
|
||||||
|
configFile = NULL;
|
||||||
homeX = false;
|
homeX = false;
|
||||||
homeY = false;
|
homeY = false;
|
||||||
homeZ = false;
|
homeZ = false;
|
||||||
|
@ -581,6 +582,44 @@ void GCodes::RunConfigurationGCodes()
|
||||||
fileToPrint = NULL;
|
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
|
// Function to handle dwell delays. Return true for
|
||||||
// dwell finished, false otherwise.
|
// dwell finished, false otherwise.
|
||||||
|
@ -1194,6 +1233,10 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
|
||||||
case 304: // Set thermistor parameters
|
case 304: // Set thermistor parameters
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 503: // Print parameters
|
||||||
|
result = SendConfigToLine();
|
||||||
|
break;
|
||||||
|
|
||||||
case 550: // Set machine name
|
case 550: // Set machine name
|
||||||
if(gb->Seen('P'))
|
if(gb->Seen('P'))
|
||||||
reprap.GetWebserver()->SetName(gb->GetString());
|
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);
|
void HandleReply(bool error, bool fromLine, char* reply, char gMOrT, int code, bool resend);
|
||||||
char* OpenFileToWrite(char* fileName, GCodeBuffer *gb);
|
char* OpenFileToWrite(char* fileName, GCodeBuffer *gb);
|
||||||
void WriteGCodeToFile(GCodeBuffer *gb);
|
void WriteGCodeToFile(GCodeBuffer *gb);
|
||||||
|
bool SendConfigToLine();
|
||||||
|
|
||||||
int8_t Heater(int8_t head);
|
int8_t Heater(int8_t head);
|
||||||
Platform* platform;
|
Platform* platform;
|
||||||
|
@ -125,6 +126,7 @@ class GCodes
|
||||||
FileStore* fileBeingPrinted;
|
FileStore* fileBeingPrinted;
|
||||||
FileStore* fileToPrint;
|
FileStore* fileToPrint;
|
||||||
FileStore* fileBeingWritten;
|
FileStore* fileBeingWritten;
|
||||||
|
FileStore* configFile;
|
||||||
int8_t selectedHead;
|
int8_t selectedHead;
|
||||||
bool homeX;
|
bool homeX;
|
||||||
bool homeY;
|
bool homeY;
|
||||||
|
|
|
@ -622,6 +622,7 @@ bool FileStore::Open(char* directory, char* fileName, bool write)
|
||||||
snprintf(scratchString, STRING_LENGTH, "%d", openReturn);
|
snprintf(scratchString, STRING_LENGTH, "%d", openReturn);
|
||||||
platform->Message(HOST_MESSAGE, scratchString);
|
platform->Message(HOST_MESSAGE, scratchString);
|
||||||
platform->Message(HOST_MESSAGE, "\n");
|
platform->Message(HOST_MESSAGE, "\n");
|
||||||
|
Close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bufferPointer = 0;
|
bufferPointer = 0;
|
||||||
|
@ -636,9 +637,10 @@ bool FileStore::Open(char* directory, char* fileName, bool write)
|
||||||
snprintf(scratchString, STRING_LENGTH, "%d", openReturn);
|
snprintf(scratchString, STRING_LENGTH, "%d", openReturn);
|
||||||
platform->Message(HOST_MESSAGE, scratchString);
|
platform->Message(HOST_MESSAGE, scratchString);
|
||||||
platform->Message(HOST_MESSAGE, "\n");
|
platform->Message(HOST_MESSAGE, "\n");
|
||||||
|
Close();
|
||||||
return false;
|
return false;
|
||||||
}
|
} else
|
||||||
bufferPointer = FILE_BUF_LEN;
|
ReadBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
inUse = true;
|
inUse = true;
|
||||||
|
|
Reference in a new issue