Further improvements to web upload and tidy-up

Further improved web file upload speed
Dealt with Eclipse code analysis warnings
Made some more functions and parameters const-correct
This commit is contained in:
David Crocker 2014-01-30 14:26:45 +00:00
parent 603c0c79c5
commit 9edaed4ac1
13 changed files with 164 additions and 151 deletions

View file

@ -24,8 +24,8 @@ Licence: GPL
#define CONFIGURATION_H #define CONFIGURATION_H
#define NAME "RepRapFirmware" #define NAME "RepRapFirmware"
#define VERSION "0.57d-dc42" #define VERSION "0.57e-dc42"
#define DATE "2014-01-29" #define DATE "2014-01-30"
#define LAST_AUTHOR "reprappro.com" #define LAST_AUTHOR "reprappro.com"
// Other firmware that we might switch to be compatible with. // Other firmware that we might switch to be compatible with.

View file

@ -146,14 +146,25 @@ void GCodes::Spin()
if(webserver->GCodeAvailable()) if(webserver->GCodeAvailable())
{ {
char b = webserver->ReadGCode(); int8_t i = 0;
if(webGCode->Put(b)) do
{ {
if(webGCode->WritingFileDirectory() != NULL) char b = webserver->ReadGCode();
WriteGCodeToFile(webGCode); if(webGCode->Put(b))
else {
webGCode->SetFinished(ActOnGcode(webGCode)); // we have a complete gcode
} if(webGCode->WritingFileDirectory() != NULL)
{
WriteGCodeToFile(webGCode);
}
else
{
webGCode->SetFinished(ActOnGcode(webGCode));
}
break; // stop after receiving a complete gcode in case we haven't finished processing it
}
++i;
} while ( i < 16 && webserver->GCodeAvailable());
platform->ClassReport("GCodes", longWait); platform->ClassReport("GCodes", longWait);
return; return;
} }
@ -300,8 +311,6 @@ bool GCodes::Pop()
void GCodes::LoadMoveBufferFromGCode(GCodeBuffer *gb, bool doingG92, bool applyLimits) void GCodes::LoadMoveBufferFromGCode(GCodeBuffer *gb, bool doingG92, bool applyLimits)
{ {
float absE;
for(uint8_t i = 0; i < DRIVES; i++) for(uint8_t i = 0; i < DRIVES; i++)
{ {
if(i < AXES) if(i < AXES)
@ -313,9 +322,9 @@ void GCodes::LoadMoveBufferFromGCode(GCodeBuffer *gb, bool doingG92, bool applyL
{ {
moveArg += moveBuffer[i]; moveArg += moveBuffer[i];
} }
if (applyLimits && axisIsHomed[i] & !doingG92) if (applyLimits && i < 2 && axisIsHomed[i] && !doingG92) // limit X and Y moves unless doing G92
{ {
if (moveArg < (i == 2 ? -5.0 : 0.0)) // limits are 0 for X, Y and -5mm for Z if (moveArg < 0.0)
{ {
moveArg = 0.0; moveArg = 0.0;
} }
@ -339,7 +348,7 @@ void GCodes::LoadMoveBufferFromGCode(GCodeBuffer *gb, bool doingG92, bool applyL
moveBuffer[i] = moveArg; moveBuffer[i] = moveArg;
else else
{ {
absE = moveArg; float absE = moveArg;
moveBuffer[i] = absE - lastPos[i - AXES]; moveBuffer[i] = absE - lastPos[i - AXES];
lastPos[i - AXES] = absE; lastPos[i - AXES] = absE;
} }
@ -876,14 +885,17 @@ char* GCodes::GetCurrentCoordinates()
return scratchString; return scratchString;
} }
char* GCodes::OpenFileToWrite(char* directory, char* fileName, GCodeBuffer *gb) void GCodes::OpenFileToWrite(const char* directory, const char* fileName, GCodeBuffer *gb)
{ {
fileBeingWritten = platform->GetFileStore(directory, fileName, true); fileBeingWritten = platform->GetFileStore(directory, fileName, true);
if(fileBeingWritten == NULL) if(fileBeingWritten == NULL)
platform->Message(HOST_MESSAGE, "Can't open GCode file for writing.\n"); {
platform->Message(HOST_MESSAGE, "Can't open GCode file for writing.\n");
}
else else
{
gb->SetWritingFileDirectory(directory); gb->SetWritingFileDirectory(directory);
}
eofStringCounter = 0; eofStringCounter = 0;
} }
@ -1099,7 +1111,7 @@ bool GCodes::StandbyHeaters()
void GCodes::SetEthernetAddress(GCodeBuffer *gb, int mCode) void GCodes::SetEthernetAddress(GCodeBuffer *gb, int mCode)
{ {
byte eth[4]; byte eth[4];
char* ipString = gb->GetString(); const char* ipString = gb->GetString();
uint8_t sp = 0; uint8_t sp = 0;
uint8_t spp = 0; uint8_t spp = 0;
uint8_t ipp = 0; uint8_t ipp = 0;
@ -1107,9 +1119,7 @@ void GCodes::SetEthernetAddress(GCodeBuffer *gb, int mCode)
{ {
if(ipString[sp] == '.') if(ipString[sp] == '.')
{ {
ipString[sp] = 0;
eth[ipp] = atoi(&ipString[spp]); eth[ipp] = atoi(&ipString[spp]);
ipString[sp] = '.';
ipp++; ipp++;
if(ipp > 3) if(ipp > 3)
{ {
@ -1244,9 +1254,6 @@ void GCodes::HandleReply(bool error, bool fromLine, const char* reply, char gMOr
bool GCodes::ActOnGcode(GCodeBuffer *gb) bool GCodes::ActOnGcode(GCodeBuffer *gb)
{ {
int code; int code;
float value;
int iValue;
char* str;
bool result = true; bool result = true;
bool error = false; bool error = false;
bool resend = false; bool resend = false;
@ -1401,9 +1408,11 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
break; break;
case 28: // Write to file case 28: // Write to file
str = gb->GetUnprecedentedString(); {
OpenFileToWrite(platform->GetGCodeDir(), str, gb); const char* str = gb->GetUnprecedentedString();
snprintf(reply, STRING_LENGTH, "Writing to file: %s", str); OpenFileToWrite(platform->GetGCodeDir(), str, gb);
snprintf(reply, STRING_LENGTH, "Writing to file: %s", str);
}
break; break;
case 29: // End of file being written; should be intercepted before getting here case 29: // End of file being written; should be intercepted before getting here
@ -1499,12 +1508,14 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
break; break;
case 114: // Deprecated case 114: // Deprecated
str = GetCurrentCoordinates();
if(str != 0)
{ {
strncpy(reply, str, STRING_LENGTH); const char* str = GetCurrentCoordinates();
} else if(str != 0)
{
strncpy(reply, str, STRING_LENGTH);
} else
result = false; result = false;
}
break; break;
case 115: // Print firmware version case 115: // Print firmware version
@ -1517,7 +1528,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
reprap.GetHeat()->SetActiveTemperature(1, gb->GetFValue()); // 0 is the bed reprap.GetHeat()->SetActiveTemperature(1, gb->GetFValue()); // 0 is the bed
reprap.GetHeat()->Activate(1); reprap.GetHeat()->Activate(1);
} }
// Deliberate fall-through to case 116 here to wait for temperatures /* no break */
case 116: // Wait for everything, especially set temperatures case 116: // Wait for everything, especially set temperatures
if(!AllMovesAreFinishedAndMoveBufferIsLoaded()) if(!AllMovesAreFinishedAndMoveBufferIsLoaded())
return false; return false;
@ -1562,6 +1573,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
case 201: // Set axis accelerations case 201: // Set axis accelerations
for(int8_t drive = 0; drive < DRIVES; drive++) for(int8_t drive = 0; drive < DRIVES; drive++)
{ {
float value;
if(gb->Seen(gCodeLetters[drive])) if(gb->Seen(gCodeLetters[drive]))
{ {
value = gb->GetFValue(); value = gb->GetFValue();
@ -1577,7 +1589,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
{ {
if(gb->Seen(gCodeLetters[drive])) if(gb->Seen(gCodeLetters[drive]))
{ {
value = gb->GetFValue()*distanceScale*0.016666667; // G Code feedrates are in mm/minute; we need mm/sec; float value = gb->GetFValue()*distanceScale*0.016666667; // G Code feedrates are in mm/minute; we need mm/sec;
platform->SetMaxFeedrate(drive, value); platform->SetMaxFeedrate(drive, value);
} }
} }
@ -1595,7 +1607,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
{ {
if(gb->Seen(gCodeLetters[axis])) if(gb->Seen(gCodeLetters[axis]))
{ {
value = gb->GetFValue()*distanceScale; float value = gb->GetFValue()*distanceScale;
platform->SetAxisLength(axis, value); platform->SetAxisLength(axis, value);
} }
} }
@ -1606,7 +1618,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
{ {
if(gb->Seen(gCodeLetters[axis])) if(gb->Seen(gCodeLetters[axis]))
{ {
value = gb->GetFValue()*distanceScale*0.016666667; float value = gb->GetFValue()*distanceScale*0.016666667;
platform->SetHomeFeedRate(axis, value); platform->SetHomeFeedRate(axis, value);
} }
} }
@ -1640,7 +1652,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
SetEthernetAddress(gb, code); SetEthernetAddress(gb, code);
else else
{ {
byte *ip = platform->IPAddress(); const byte *ip = platform->IPAddress();
snprintf(reply, STRING_LENGTH, "IP address: %d.%d.%d.%d\n ", ip[0], ip[1], ip[2], ip[3]); snprintf(reply, STRING_LENGTH, "IP address: %d.%d.%d.%d\n ", ip[0], ip[1], ip[2], ip[3]);
} }
break; break;
@ -1650,7 +1662,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
SetEthernetAddress(gb, code); SetEthernetAddress(gb, code);
else else
{ {
byte *nm = platform->NetMask(); const byte *nm = platform->NetMask();
snprintf(reply, STRING_LENGTH, "Net mask: %d.%d.%d.%d\n ", nm[0], nm[1], nm[2], nm[3]); snprintf(reply, STRING_LENGTH, "Net mask: %d.%d.%d.%d\n ", nm[0], nm[1], nm[2], nm[3]);
} }
break; break;
@ -1660,7 +1672,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
SetEthernetAddress(gb, code); SetEthernetAddress(gb, code);
else else
{ {
byte *gw = platform->GateWay(); const byte *gw = platform->GateWay();
snprintf(reply, STRING_LENGTH, "Gateway: %d.%d.%d.%d\n ", gw[0], gw[1], gw[2], gw[3]); snprintf(reply, STRING_LENGTH, "Gateway: %d.%d.%d.%d\n ", gw[0], gw[1], gw[2], gw[3]);
} }
break; break;
@ -1673,7 +1685,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
case 556: // Axis compensation case 556: // Axis compensation
if(gb->Seen('S')) if(gb->Seen('S'))
{ {
value = gb->GetFValue(); float value = gb->GetFValue();
for(int8_t axis = 0; axis < AXES; axis++) for(int8_t axis = 0; axis < AXES; axis++)
if(gb->Seen(gCodeLetters[axis])) if(gb->Seen(gCodeLetters[axis]))
reprap.GetMove()->SetAxisCompensation(axis, gb->GetFValue()/value); reprap.GetMove()->SetAxisCompensation(axis, gb->GetFValue()/value);
@ -1683,7 +1695,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
case 557: // Set Z probe point coordinates case 557: // Set Z probe point coordinates
if(gb->Seen('P')) if(gb->Seen('P'))
{ {
iValue = gb->GetIValue(); int iValue = gb->GetIValue();
if(gb->Seen(gCodeLetters[X_AXIS])) if(gb->Seen(gCodeLetters[X_AXIS]))
reprap.GetMove()->SetXBedProbePoint(iValue, gb->GetFValue()); reprap.GetMove()->SetXBedProbePoint(iValue, gb->GetFValue());
if(gb->Seen(gCodeLetters[Y_AXIS])) if(gb->Seen(gCodeLetters[Y_AXIS]))
@ -1703,18 +1715,23 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
break; break;
case 559: // Upload config.g case 559: // Upload config.g
if(gb->Seen('P')) {
str = gb->GetString(); const char* str;
else if(gb->Seen('P'))
str = platform->GetConfigFile(); str = gb->GetString();
OpenFileToWrite(platform->GetSysDir(), str, gb); else
snprintf(reply, STRING_LENGTH, "Writing to file: %s", str); str = platform->GetConfigFile();
OpenFileToWrite(platform->GetSysDir(), str, gb);
snprintf(reply, STRING_LENGTH, "Writing to file: %s", str);
}
break; break;
case 560: // Upload reprap.htm case 560: // Upload reprap.htm
str = INDEX_PAGE; {
OpenFileToWrite(platform->GetWebDir(), str, gb); const char* str = INDEX_PAGE;
snprintf(reply, STRING_LENGTH, "Writing to file: %s", str); OpenFileToWrite(platform->GetWebDir(), str, gb);
snprintf(reply, STRING_LENGTH, "Writing to file: %s", str);
}
break; break;
case 561: case 561:
@ -1724,7 +1741,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
case 562: // Reset temperature fault - use with great caution case 562: // Reset temperature fault - use with great caution
if(gb->Seen('P')) if(gb->Seen('P'))
{ {
iValue = gb->GetIValue(); int iValue = gb->GetIValue();
reprap.GetHeat()->ResetFault(iValue); reprap.GetHeat()->ResetFault(iValue);
} }
break; break;
@ -1755,7 +1772,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
{ {
if(gb->Seen(gCodeLetters[i])) if(gb->Seen(gCodeLetters[i]))
{ {
value = gb->GetFValue(); // mA float value = gb->GetFValue(); // mA
platform->SetMotorCurrent(i, value); platform->SetMotorCurrent(i, value);
} }
} }
@ -1826,7 +1843,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
// This class stores a single G Code and provides functions to allow it to be parsed // This class stores a single G Code and provides functions to allow it to be parsed
GCodeBuffer::GCodeBuffer(Platform* p, char* id) GCodeBuffer::GCodeBuffer(Platform* p, const char* id)
{ {
platform = p; platform = p;
identity = id; identity = id;
@ -1843,7 +1860,7 @@ void GCodeBuffer::Init()
int GCodeBuffer::CheckSum() int GCodeBuffer::CheckSum()
{ {
int cs = 0; int cs = 0;
for(int i = 0; gcodeBuffer[i] != '*' && gcodeBuffer[i] != NULL; i++) for(int i = 0; gcodeBuffer[i] != '*' && gcodeBuffer[i] != 0; i++)
cs = cs ^ gcodeBuffer[i]; cs = cs ^ gcodeBuffer[i];
cs &= 0xff; // Defensive programming... cs &= 0xff; // Defensive programming...
return cs; return cs;
@ -1864,7 +1881,7 @@ bool GCodeBuffer::Put(char c)
{ {
gcodeBuffer[gcodePointer] = 0; gcodeBuffer[gcodePointer] = 0;
Init(); Init();
if(reprap.Debug() && gcodeBuffer[0]) // Don't bother with blank/comment lines if(reprap.Debug() && gcodeBuffer[0] && !writingFileDirectory) // Don't bother with blank/comment lines
{ {
platform->Message(HOST_MESSAGE, identity); platform->Message(HOST_MESSAGE, identity);
platform->Message(HOST_MESSAGE, gcodeBuffer); platform->Message(HOST_MESSAGE, gcodeBuffer);
@ -1966,14 +1983,14 @@ float GCodeBuffer::GetFValue()
// It will be the whole of the rest of the GCode string, so strings // It will be the whole of the rest of the GCode string, so strings
// should always be the last parameter. // should always be the last parameter.
char* GCodeBuffer::GetString() const char* GCodeBuffer::GetString()
{ {
if(readPointer < 0) if(readPointer < 0)
{ {
platform->Message(HOST_MESSAGE, "GCodes: Attempt to read a GCode string before a search.\n"); platform->Message(HOST_MESSAGE, "GCodes: Attempt to read a GCode string before a search.\n");
return ""; return "";
} }
char* result = &gcodeBuffer[readPointer+1]; const char* result = &gcodeBuffer[readPointer+1];
readPointer = -1; readPointer = -1;
return result; return result;
} }
@ -1989,7 +2006,7 @@ char* GCodeBuffer::GetString()
// preference use GetString() which requires the string to have // preference use GetString() which requires the string to have
// been preceded by a tag letter. // been preceded by a tag letter.
char* GCodeBuffer::GetUnprecedentedString() const char* GCodeBuffer::GetUnprecedentedString()
{ {
readPointer = 0; readPointer = 0;
while(gcodeBuffer[readPointer] && gcodeBuffer[readPointer] != ' ') while(gcodeBuffer[readPointer] && gcodeBuffer[readPointer] != ' ')

View file

@ -32,31 +32,31 @@ Licence: GPL
class GCodeBuffer class GCodeBuffer
{ {
public: public:
GCodeBuffer(Platform* p, char* id); GCodeBuffer(Platform* p, const char* id);
void Init(); void Init();
bool Put(char c); bool Put(char c);
bool Seen(char c); bool Seen(char c);
float GetFValue(); float GetFValue();
int GetIValue(); int GetIValue();
long GetLValue(); long GetLValue();
char* GetUnprecedentedString(); const char* GetUnprecedentedString();
char* GetString(); const char* GetString();
char* Buffer(); const char* Buffer();
bool Finished() const; bool Finished() const;
void SetFinished(bool f); void SetFinished(bool f);
char* WritingFileDirectory() const; const char* WritingFileDirectory() const;
void SetWritingFileDirectory(char* wfd); void SetWritingFileDirectory(const char* wfd);
private: private:
int CheckSum(); int CheckSum();
Platform* platform; Platform* platform;
char gcodeBuffer[GCODE_LENGTH]; char gcodeBuffer[GCODE_LENGTH];
char* identity; const char* identity;
int gcodePointer; int gcodePointer;
int readPointer; int readPointer;
bool inComment; bool inComment;
bool finished; bool finished;
char* writingFileDirectory; const char* writingFileDirectory;
}; };
//**************************************************************************************************** //****************************************************************************************************
@ -108,7 +108,7 @@ class GCodes
bool StandbyHeaters(); bool StandbyHeaters();
void SetEthernetAddress(GCodeBuffer *gb, int mCode); void SetEthernetAddress(GCodeBuffer *gb, int mCode);
void HandleReply(bool error, bool fromLine, const char* reply, char gMOrT, int code, bool resend); void HandleReply(bool error, bool fromLine, const char* reply, char gMOrT, int code, bool resend);
char* OpenFileToWrite(char* directory, char* fileName, GCodeBuffer *gb); void OpenFileToWrite(const char* directory, const char* fileName, GCodeBuffer *gb);
void WriteGCodeToFile(GCodeBuffer *gb); void WriteGCodeToFile(GCodeBuffer *gb);
bool SendConfigToLine(); bool SendConfigToLine();
void WriteHTMLToFile(char b, GCodeBuffer *gb); void WriteHTMLToFile(char b, GCodeBuffer *gb);
@ -172,7 +172,7 @@ inline int GCodeBuffer::GetIValue()
return (int)GetLValue(); return (int)GetLValue();
} }
inline char* GCodeBuffer::Buffer() inline const char* GCodeBuffer::Buffer()
{ {
return gcodeBuffer; return gcodeBuffer;
} }
@ -187,12 +187,12 @@ inline void GCodeBuffer::SetFinished(bool f)
finished = f; finished = f;
} }
inline char* GCodeBuffer::WritingFileDirectory() const inline const char* GCodeBuffer::WritingFileDirectory() const
{ {
return writingFileDirectory; return writingFileDirectory;
} }
inline void GCodeBuffer::SetWritingFileDirectory(char* wfd) inline void GCodeBuffer::SetWritingFileDirectory(const char* wfd)
{ {
writingFileDirectory = wfd; writingFileDirectory = wfd;
} }

5
Heat.h
View file

@ -156,10 +156,7 @@ inline void Heat::SetStandbyTemperature(int8_t heater, const float& t)
inline float Heat::GetStandbyTemperature(int8_t heater) inline float Heat::GetStandbyTemperature(int8_t heater)
{ {
if (heater >= 0 && heater < HEATERS) return (heater >= 0 && heater < HEATERS) ? pids[heater]->GetStandbyTemperature() : ABS_ZERO;
{
return pids[heater]->GetStandbyTemperature();
}
} }
inline float Heat::GetTemperature(int8_t heater) inline float Heat::GetTemperature(int8_t heater)

View file

@ -763,7 +763,7 @@ void FileStore::Write(char b)
WriteBuffer(); WriteBuffer();
} }
void FileStore::Write(char* b) void FileStore::Write(const char* b)
{ {
if(!inUse) if(!inUse)
{ {

View file

@ -368,7 +368,7 @@ public:
int8_t Status(); // Returns OR of IOStatus int8_t Status(); // Returns OR of IOStatus
bool Read(char& b); bool Read(char& b);
void Write(char b); void Write(char b);
void Write(char* s); void Write(const char* s);
void Close(); void Close();
void GoToEnd(); // Position the file at the end (so you can write on the end). void GoToEnd(); // Position the file at the end (so you can write on the end).
unsigned long Length(); // File size in bytes unsigned long Length(); // File size in bytes
@ -418,7 +418,7 @@ class Platform
void Exit(); // Shut down tidily. Calling Init after calling this should reset to the beginning void Exit(); // Shut down tidily. Calling Init after calling this should reset to the beginning
Compatibility Emulating(); Compatibility Emulating() const;
void SetEmulating(Compatibility c); void SetEmulating(Compatibility c);
@ -439,24 +439,24 @@ class Platform
// Communications and data storage // Communications and data storage
Network* GetNetwork(); Network* GetNetwork();
Line* GetLine(); Line* GetLine() const;
void SetIPAddress(byte ip[]); void SetIPAddress(byte ip[]);
byte* IPAddress(); const byte* IPAddress() const;
void SetNetMask(byte nm[]); void SetNetMask(byte nm[]);
byte* NetMask(); const byte* NetMask() const;
void SetGateWay(byte gw[]); void SetGateWay(byte gw[]);
byte* GateWay(); const byte* GateWay() const;
friend class FileStore; friend class FileStore;
MassStorage* GetMassStorage(); MassStorage* GetMassStorage();
FileStore* GetFileStore(const char* directory, const char* fileName, bool write); FileStore* GetFileStore(const char* directory, const char* fileName, bool write);
void StartNetwork(); void StartNetwork();
char* GetWebDir(); // Where the htm etc files are const char* GetWebDir() const; // Where the htm etc files are
char* GetGCodeDir(); // Where the gcodes are const char* GetGCodeDir() const; // Where the gcodes are
char* GetSysDir(); // Where the system files are const char* GetSysDir() const; // Where the system files are
char* GetTempDir(); // Where temporary files are const char* GetTempDir() const; // Where temporary files are
char* GetConfigFile(); // Where the configuration is stored (in the system dir). const char* GetConfigFile() const; // Where the configuration is stored (in the system dir).
void Message(char type, const char* message); // Send a message. Messages may simply flash an LED, or, void Message(char type, const char* message); // Send a message. Messages may simply flash an LED, or,
// say, display the messages on an LCD. This may also transmit the messages to the host. // say, display the messages on an LCD. This may also transmit the messages to the host.
@ -470,21 +470,21 @@ class Platform
void Step(byte drive); void Step(byte drive);
void Disable(byte drive); // There is no drive enable; drives get enabled automatically the first time they are used. void Disable(byte drive); // There is no drive enable; drives get enabled automatically the first time they are used.
void SetMotorCurrent(byte drive, float current); void SetMotorCurrent(byte drive, float current);
float DriveStepsPerUnit(int8_t drive); float DriveStepsPerUnit(int8_t drive) const;
void SetDriveStepsPerUnit(int8_t drive, float value); void SetDriveStepsPerUnit(int8_t drive, float value);
float Acceleration(int8_t drive); float Acceleration(int8_t drive) const;
void SetAcceleration(int8_t drive, float value); void SetAcceleration(int8_t drive, float value);
float MaxFeedrate(int8_t drive); float MaxFeedrate(int8_t drive) const;
void SetMaxFeedrate(int8_t drive, float value); void SetMaxFeedrate(int8_t drive, float value);
float InstantDv(int8_t drive); float InstantDv(int8_t drive) const;
float HomeFeedRate(int8_t axis); float HomeFeedRate(int8_t axis) const;
void SetHomeFeedRate(int8_t axis, float value); void SetHomeFeedRate(int8_t axis, float value);
EndStopHit Stopped(int8_t drive); EndStopHit Stopped(int8_t drive);
float AxisLength(int8_t axis); float AxisLength(int8_t axis) const;
void SetAxisLength(int8_t axis, float value); void SetAxisLength(int8_t axis, float value);
bool HighStopButNotLow(int8_t axis); bool HighStopButNotLow(int8_t axis) const;
float ZProbeStopHeight(); float ZProbeStopHeight() const;
void SetZProbeStopHeight(float z); void SetZProbeStopHeight(float z);
int ZProbe() const; int ZProbe() const;
int ZProbeOnVal() const; int ZProbeOnVal() const;
@ -496,15 +496,15 @@ class Platform
float GetTemperature(int8_t heater); // Result is in degrees celsius float GetTemperature(int8_t heater); // Result is in degrees celsius
void SetHeater(int8_t heater, const float& power); // power is a fraction in [0,1] void SetHeater(int8_t heater, const float& power); // power is a fraction in [0,1]
float PidKp(int8_t heater); float PidKp(int8_t heater) const;
float PidKi(int8_t heater); float PidKi(int8_t heater) const;
float PidKd(int8_t heater); float PidKd(int8_t heater) const;
float FullPidBand(int8_t heater); float FullPidBand(int8_t heater) const;
float PidMin(int8_t heater); float PidMin(int8_t heater) const;
float PidMax(int8_t heater); float PidMax(int8_t heater) const;
float DMix(int8_t heater); float DMix(int8_t heater) const;
bool UsePID(int8_t heater); bool UsePID(int8_t heater) const;
float HeatSampleTime(); float HeatSampleTime() const;
void CoolingFan(float speed); void CoolingFan(float speed);
//void SetHeatOn(int8_t ho); //TEMPORARY - this will go away... //void SetHeatOn(int8_t ho); //TEMPORARY - this will go away...
@ -525,7 +525,7 @@ class Platform
Compatibility compatibility; Compatibility compatibility;
void InitialiseInterrupts(); void InitialiseInterrupts();
int GetRawZHeight(); int GetRawZHeight() const;
// DRIVES // DRIVES
@ -570,7 +570,7 @@ class Platform
// HEATERS - Bed is assumed to be the first // HEATERS - Bed is assumed to be the first
int GetRawTemperature(byte heater); int GetRawTemperature(byte heater) const;
int8_t tempSensePins[HEATERS]; int8_t tempSensePins[HEATERS];
int8_t heatOnPins[HEATERS]; int8_t heatOnPins[HEATERS];
@ -637,7 +637,7 @@ inline void Platform::Exit()
active = false; active = false;
} }
inline Compatibility Platform::Emulating() inline Compatibility Platform::Emulating() const
{ {
if(compatibility == reprapFirmware) if(compatibility == reprapFirmware)
return me; return me;
@ -658,34 +658,34 @@ inline void Platform::SetEmulating(Compatibility c)
// Where the htm etc files are // Where the htm etc files are
inline char* Platform::GetWebDir() inline const char* Platform::GetWebDir() const
{ {
return webDir; return webDir;
} }
// Where the gcodes are // Where the gcodes are
inline char* Platform::GetGCodeDir() inline const char* Platform::GetGCodeDir() const
{ {
return gcodeDir; return gcodeDir;
} }
// Where the system files are // Where the system files are
inline char* Platform::GetSysDir() inline const char* Platform::GetSysDir() const
{ {
return sysDir; return sysDir;
} }
// Where the temporary files are // Where the temporary files are
inline char* Platform::GetTempDir() inline const char* Platform::GetTempDir() const
{ {
return tempDir; return tempDir;
} }
inline char* Platform::GetConfigFile() inline const char* Platform::GetConfigFile() const
{ {
return configFile; return configFile;
} }
@ -696,7 +696,7 @@ inline char* Platform::GetConfigFile()
// Drive the RepRap machine - Movement // Drive the RepRap machine - Movement
inline float Platform::DriveStepsPerUnit(int8_t drive) inline float Platform::DriveStepsPerUnit(int8_t drive) const
{ {
return driveStepsPerUnit[drive]; return driveStepsPerUnit[drive];
} }
@ -706,7 +706,7 @@ inline void Platform::SetDriveStepsPerUnit(int8_t drive, float value)
driveStepsPerUnit[drive] = value; driveStepsPerUnit[drive] = value;
} }
inline float Platform::Acceleration(int8_t drive) inline float Platform::Acceleration(int8_t drive) const
{ {
return accelerations[drive]; return accelerations[drive];
} }
@ -716,14 +716,14 @@ inline void Platform::SetAcceleration(int8_t drive, float value)
accelerations[drive] = value; accelerations[drive] = value;
} }
inline float Platform::InstantDv(int8_t drive) inline float Platform::InstantDv(int8_t drive) const
{ {
return instantDvs[drive]; return instantDvs[drive];
} }
inline bool Platform::HighStopButNotLow(int8_t axis) inline bool Platform::HighStopButNotLow(int8_t axis) const
{ {
return (lowStopPins[axis] < 0) && (highStopPins[axis] >= 0); return (lowStopPins[axis] < 0) && (highStopPins[axis] >= 0);
} }
inline void Platform::SetDirection(byte drive, bool direction) inline void Platform::SetDirection(byte drive, bool direction)
@ -783,7 +783,7 @@ inline void Platform::SetMotorCurrent(byte drive, float current)
mcp.setVolatileWiper(potWipes[drive], pot); mcp.setVolatileWiper(potWipes[drive], pot);
} }
inline float Platform::HomeFeedRate(int8_t axis) inline float Platform::HomeFeedRate(int8_t axis) const
{ {
return homeFeedrates[axis]; return homeFeedrates[axis];
} }
@ -793,7 +793,7 @@ inline void Platform::SetHomeFeedRate(int8_t axis, float value)
homeFeedrates[axis] = value; homeFeedrates[axis] = value;
} }
inline float Platform::AxisLength(int8_t axis) inline float Platform::AxisLength(int8_t axis) const
{ {
return axisLengths[axis]; return axisLengths[axis];
} }
@ -803,7 +803,7 @@ inline void Platform::SetAxisLength(int8_t axis, float value)
axisLengths[axis] = value; axisLengths[axis] = value;
} }
inline float Platform::MaxFeedrate(int8_t drive) inline float Platform::MaxFeedrate(int8_t drive) const
{ {
return maxFeedrates[drive]; return maxFeedrates[drive];
} }
@ -813,7 +813,7 @@ inline void Platform::SetMaxFeedrate(int8_t drive, float value)
maxFeedrates[drive] = value; maxFeedrates[drive] = value;
} }
inline int Platform::GetRawZHeight() inline int Platform::GetRawZHeight() const
{ {
return (zProbeType != 0) ? analogRead(zProbePin) : 0; return (zProbeType != 0) ? analogRead(zProbePin) : 0;
} }
@ -836,7 +836,7 @@ inline int Platform::ZProbeOnVal() const
: 0; : 0;
} }
inline float Platform::ZProbeStopHeight() inline float Platform::ZProbeStopHeight() const
{ {
return zProbeStopHeight; return zProbeStopHeight;
} }
@ -887,55 +887,55 @@ inline void Platform::PollZHeight()
// Drive the RepRap machine - Heat and temperature // Drive the RepRap machine - Heat and temperature
inline int Platform::GetRawTemperature(byte heater) inline int Platform::GetRawTemperature(byte heater) const
{ {
if(tempSensePins[heater] >= 0) if(tempSensePins[heater] >= 0)
return analogRead(tempSensePins[heater]); return analogRead(tempSensePins[heater]);
return 0; return 0;
} }
inline float Platform::HeatSampleTime() inline float Platform::HeatSampleTime() const
{ {
return heatSampleTime; return heatSampleTime;
} }
inline bool Platform::UsePID(int8_t heater) inline bool Platform::UsePID(int8_t heater) const
{ {
return usePID[heater]; return usePID[heater];
} }
inline float Platform::PidKi(int8_t heater) inline float Platform::PidKi(int8_t heater) const
{ {
return pidKis[heater]*heatSampleTime; return pidKis[heater]*heatSampleTime;
} }
inline float Platform::PidKd(int8_t heater) inline float Platform::PidKd(int8_t heater) const
{ {
return pidKds[heater]/heatSampleTime; return pidKds[heater]/heatSampleTime;
} }
inline float Platform::PidKp(int8_t heater) inline float Platform::PidKp(int8_t heater) const
{ {
return pidKps[heater]; return pidKps[heater];
} }
inline float Platform::FullPidBand(int8_t heater) inline float Platform::FullPidBand(int8_t heater) const
{ {
return fullPidBand[heater]; return fullPidBand[heater];
} }
inline float Platform::PidMin(int8_t heater) inline float Platform::PidMin(int8_t heater) const
{ {
return pidMin[heater]; return pidMin[heater];
} }
inline float Platform::PidMax(int8_t heater) inline float Platform::PidMax(int8_t heater) const
{ {
return pidMax[heater]/PidKi(heater); return pidMax[heater]/PidKi(heater);
} }
inline float Platform::DMix(int8_t heater) inline float Platform::DMix(int8_t heater) const
{ {
return dMix[heater]; return dMix[heater];
} }
@ -985,7 +985,7 @@ inline void Platform::SetIPAddress(byte ip[])
ipAddress[i] = ip[i]; ipAddress[i] = ip[i];
} }
inline byte* Platform::IPAddress() inline const byte* Platform::IPAddress() const
{ {
return ipAddress; return ipAddress;
} }
@ -996,7 +996,7 @@ inline void Platform::SetNetMask(byte nm[])
netMask[i] = nm[i]; netMask[i] = nm[i];
} }
inline byte* Platform::NetMask() inline const byte* Platform::NetMask() const
{ {
return netMask; return netMask;
} }
@ -1007,12 +1007,12 @@ inline void Platform::SetGateWay(byte gw[])
gateWay[i] = gw[i]; gateWay[i] = gw[i];
} }
inline byte* Platform::GateWay() inline const byte* Platform::GateWay() const
{ {
return gateWay; return gateWay;
} }
inline Line* Platform::GetLine() inline Line* Platform::GetLine() const
{ {
return line; return line;
} }

View file

@ -157,9 +157,8 @@ RepRap reprap;
// Do nothing more in the constructor; put what you want in RepRap:Init() // Do nothing more in the constructor; put what you want in RepRap:Init()
RepRap::RepRap() RepRap::RepRap() : active(false), debug(false)
{ {
active = false;
platform = new Platform(); platform = new Platform();
webserver = new Webserver(platform); webserver = new Webserver(platform);
gCodes = new GCodes(platform, webserver); gCodes = new GCodes(platform, webserver);

View file

@ -31,7 +31,7 @@ class Move;
class Heat; class Heat;
class RepRap; class RepRap;
// A single instace of the RepRap class contains all the others // A single instance of the RepRap class contains all the others
extern RepRap reprap; extern RepRap reprap;

View file

@ -32,13 +32,13 @@ class RepRap
void Exit(); void Exit();
void Interrupt(); void Interrupt();
void Diagnostics(); void Diagnostics();
bool Debug(); bool Debug() const;
void SetDebug(bool d); void SetDebug(bool d);
Platform* GetPlatform(); Platform* GetPlatform() const;
Move* GetMove(); Move* GetMove() const;
Heat* GetHeat(); Heat* GetHeat() const;
GCodes* GetGCodes(); GCodes* GetGCodes() const;
Webserver* GetWebserver(); Webserver* GetWebserver() const;
private: private:
@ -51,12 +51,12 @@ class RepRap
bool debug; bool debug;
}; };
inline Platform* RepRap::GetPlatform() { return platform; } inline Platform* RepRap::GetPlatform() const { return platform; }
inline Move* RepRap::GetMove() { return move; } inline Move* RepRap::GetMove() const { return move; }
inline Heat* RepRap::GetHeat() { return heat; } inline Heat* RepRap::GetHeat() const { return heat; }
inline GCodes* RepRap::GetGCodes() { return gCodes; } inline GCodes* RepRap::GetGCodes() const { return gCodes; }
inline Webserver* RepRap::GetWebserver() { return webserver; } inline Webserver* RepRap::GetWebserver() const { return webserver; }
inline bool RepRap::Debug() { return debug; } inline bool RepRap::Debug() const { return debug; }
inline void RepRap::SetDebug(bool d) inline void RepRap::SetDebug(bool d)
{ {

View file

@ -1,6 +1,5 @@
; RepRapPro Ormerod ; RepRapPro Ormerod
; Standard configuration G Codes ; Standard configuration G Codes
M111 S1; Debug on
M550 POrmerod; Set the machine's name M550 POrmerod; Set the machine's name
M551 Preprap; Set the password M551 Preprap; Set the password
M552 P192.168.1.14; Set the IP address M552 P192.168.1.14; Set the IP address

View file

@ -150,6 +150,7 @@ bool Webserver::LoadGcodeBuffer(const char* gc, bool convertWeb)
} }
} }
while (c != 0); while (c != 0);
return true;
} }
// Process a null-terminated gcode // Process a null-terminated gcode

View file

@ -270,7 +270,7 @@ static void ethernet_configure_interface(unsigned char ipAddress[], unsigned cha
/** \brief Create ethernet task, for ethernet management. /** \brief Create ethernet task, for ethernet management.
* *
*/ */
void init_ethernet(unsigned char ipAddress[], unsigned char netMask[], unsigned char gateWay[]) void init_ethernet(const unsigned char ipAddress[], const unsigned char netMask[], const unsigned char gateWay[])
{ {
/* Initialize lwIP */ /* Initialize lwIP */
lwip_init(); lwip_init();

View file

@ -62,7 +62,7 @@ bool status_link_up();//*****************************AB
*/ */
//void init_ethernet(void); //void init_ethernet(void);
void init_ethernet(unsigned char ipAddress[], unsigned char netMask[], unsigned char gateWay[]); void init_ethernet(const unsigned char ipAddress[], const unsigned char netMask[], const unsigned char gateWay[]);
struct netif* GetConfiguration(); struct netif* GetConfiguration();