Version 0.65i

Improved speed of response to M220 command
Limit length of text returned in response to rr_name web command, stop
on first control character, and escape and quote or backslash characters
This commit is contained in:
David Crocker 2014-06-21 14:01:23 +01:00
parent 6ce679160c
commit fe2b31a550
8 changed files with 94 additions and 40 deletions

View file

@ -1,4 +1,4 @@
Additional functionality in 0.65f-dc42 release compared to RRP 0.65e:
Additional functionality in 0.65i-dc42 release compared to RRP 0.65e:
* The Duet can serve all the files needed by the web interface
@ -26,7 +26,7 @@ Additional functionality in 0.65f-dc42 release compared to RRP 0.65e:
* Option to invert cooling fan PWM
* Additional z-probe type 2 is supported, for boards that support more than one type of z-probe
* Additional z-probe type 2 is supported, for z-probe boards that incorporate more than one type of z-probe
* Separate G31 parameters can be saved for z-probe types 0, 1/2, and 3
@ -42,8 +42,12 @@ Additional functionality in 0.65f-dc42 release compared to RRP 0.65e:
* The USB port is responsive immediately after power up or reset even when no Ethernet cable is connected
* Bug fix: uploading file whose name includes an uppercase G now works
Additional functionality in web interface 0.91 compared to RRP 0.65:
* Bug fix: Setting a machine name that contains a quote or backslash character no longer causes the webserver to return a bad JSON response in response to the rr_name request
Additional functionality in web interface 0.95 compared to RRP 0.65:
* Faster (>6Mbytes/min), more reliable file uploading, with reporting and graceful recovery if an upload fails
@ -59,6 +63,8 @@ Additional functionality in web interface 0.91 compared to RRP 0.65:
* "Upload & Print" button (replaces direct web print button, uploads to the SD card first for more reliable printing)
* Extruder box reports total filament extruded, not the amount extruded in the last move
* The extruder box reports total filament extruded, not the amount extruded in the last move
* Additional status Halted is shown (if emergency stop has been used) as well as Ready and Active
* The Print Status tab includes slider controls to allow the speed and extrusion factor to be adjusted during printing

View file

@ -24,8 +24,8 @@ Licence: GPL
#define CONFIGURATION_H
#define NAME "RepRapFirmware"
#define VERSION "0.65h-dc42"
#define DATE "2014-06-18"
#define VERSION "0.65i-dc42"
#define DATE "2014-06-20"
#define LAST_AUTHOR "reprappro & dc42"
// Other firmware that we might switch to be compatible with.

View file

@ -92,7 +92,10 @@ void GCodes::Reset()
cannedCycleMoveQueued = false;
gFeedRate = platform->MaxFeedrate(Z_AXIS); // Typically the slowest
speedFactor = 1.0/60.0; // default is just to convert from mm/minute to mm/second
extrusionFactor = 1.0;
for (size_t i = 0; i < DRIVES - AXES; ++i)
{
extrusionFactors[i] = 1.0;
}
}
void GCodes::DoFilePrint(GCodeBuffer* gb)
@ -410,7 +413,7 @@ void GCodes::LoadMoveBufferFromGCode(GCodeBuffer *gb, bool doingG92, bool applyL
}
if(extruderString[sp] == ':')
{
eArg[hp] = (atoff(&extruderString[fp]))*distanceScale;
eArg[hp] = (atoff(&extruderString[fp])) * distanceScale * extrusionFactors[hp];
hp++;
if(hp >= numDrives)
{
@ -428,7 +431,7 @@ void GCodes::LoadMoveBufferFromGCode(GCodeBuffer *gb, bool doingG92, bool applyL
}
}
//capture the last drive step amount in the string (or the only one in the case of only one extruder)
eArg[hp] = (atoff(&extruderString[fp])) * distanceScale * extrusionFactor;
eArg[hp] = (atoff(&extruderString[fp])) * distanceScale * extrusionFactors[hp];
//set the move buffer for each extruder drive
for(int j=0;j<numDrives;j++)
@ -1026,7 +1029,7 @@ bool GCodes::SetPrintZProbe(GCodeBuffer* gb, char* reply)
//Fixed to deal with multiple extruders
char* GCodes::GetCurrentCoordinates()
const char* GCodes::GetCurrentCoordinates()
{
float liveCoordinates[DRIVES + 1];
reprap.GetMove()->LiveCoordinates(liveCoordinates);
@ -2145,14 +2148,33 @@ bool GCodes::HandleMcode(GCodeBuffer* gb)
case 220: // set speed factor override percentage
if (gb->Seen('S'))
{
speedFactor = gb->GetFValue()/(60 * 100.0); // include the conversion from mm/minute to mm/second
float newSpeedFactor = gb->GetFValue()/(60 * 100.0); // include the conversion from mm/minute to mm/second
if (newSpeedFactor > 0)
{
gFeedRate *= newSpeedFactor/speedFactor;
speedFactor = newSpeedFactor;
}
}
break;
case 221: // set extrusion factor override percentage
if (gb->Seen('S'))
//FIXME: need to allow multiple colon-separated parameters for mixing extruders
if (gb->Seen('S')) // S parameter sets the override percentage
{
extrusionFactor = gb->GetFValue()/100.0;
float extrusionFactor = gb->GetFValue()/100.0;
int head;
if (gb->Seen('P')) // P parameter (if present) selects the head
{
head = gb->GetIValue();
}
else
{
head = selectedHead;
}
if (head >= 1 && head < DRIVES - AXES + 1 && extrusionFactor >= 0)
{
extrusionFactors[head - 1] = extrusionFactor;
}
}
break;

View file

@ -78,21 +78,23 @@ class GCodes
void Spin(); // Called in a tight loop to make this class work
void Init(); // Set it up
void Exit(); // Shut it down
void Reset();
void Reset(); // Reset some parameter to defaults
bool RunConfigurationGCodes(); // Run the configuration G Code file on reboot
bool ReadMove(float* m, bool& ce); // Called by the Move class to get a movement set by the last G Code
void QueueFileToPrint(const char* fileName); // Open a file of G Codes to run
void DeleteFile(const char* fileName); // Does what it says
bool GetProbeCoordinates(int count, float& x, float& y, float& z); // Get pre-recorded probe coordinates
char* GetCurrentCoordinates(); // Get where we are as a string
const char* GetCurrentCoordinates(); // Get where we are as a string
bool PrintingAFile() const; // Are we in the middle of printing a file?
void Diagnostics(); // Send helpful information out
int8_t GetSelectedHead() const; // return which tool is selected
bool HaveIncomingData() const; // Is there something that we have to do?
bool GetAxisIsHomed(uint8_t axis) const { return axisIsHomed[axis]; } // Is the axis at 0?
void SetAxisIsHomed(uint8_t axis) { axisIsHomed[axis] = true; }
float GetExtruderPosition(uint8_t extruder) const;
void PauseSDPrint();
void SetAxisIsHomed(uint8_t axis) { axisIsHomed[axis] = true; } // Tell us that the axis is now homes
float GetExtruderPosition(uint8_t extruder) const; // Get the amount of filament extruded
void PauseSDPrint(); // Pause the current print from SD card
float GetSpeedFactor() const { return speedFactor; } // Return the current speed factor
const float *GetExtrusionFactors() const { return extrusionFactors; } // Return the current extrusion factors
private:
@ -101,13 +103,13 @@ class GCodes
bool DoCannedCycleMove(bool ce); // Do a move from an internally programmed canned cycle
bool DoFileCannedCycles(const char* fileName); // Run a GCode macro in a file
bool FileCannedCyclesReturn(); // End a macro
bool ActOnGcode(GCodeBuffer* gb); // Do the G Code
bool HandleGcode(GCodeBuffer* gb);
bool HandleMcode(GCodeBuffer* gb);
bool HandleTcode(GCodeBuffer* gb);
int SetUpMove(GCodeBuffer* gb);
bool ActOnGcode(GCodeBuffer* gb); // Do the G/M/T Code
bool HandleGcode(GCodeBuffer* gb); // Process a G code
bool HandleMcode(GCodeBuffer* gb); // Process a M code
bool HandleTcode(GCodeBuffer* gb); // Process a T code
int SetUpMove(GCodeBuffer* gb); // Pass a move on to the Move module
bool DoDwell(GCodeBuffer *gb); // Wait for a bit
bool DoDwellTime(float dwell);
bool DoDwellTime(float dwell); // Really wait for a bit
bool DoHome(char *reply, bool& error); // Home some axes
bool DoSingleZProbeAtPoint(); // Probe at a given point
bool DoSingleZProbe(); // Probe where we are
@ -133,9 +135,10 @@ class GCodes
bool SendConfigToLine(); // Deal with M503
void WriteHTMLToFile(char b, GCodeBuffer *gb); // Save an HTML file (usually to upload a new web interface)
bool OffsetAxes(GCodeBuffer *gb); // Set offsets - deprecated, use G10
void SetPidParameters(GCodeBuffer *gb, int heater, char reply[STRING_LENGTH]);
void SetHeaterParameters(GCodeBuffer *gb, char reply[STRING_LENGTH]);
int8_t Heater(int8_t head) const;
void SetPidParameters(GCodeBuffer *gb, int heater, char reply[STRING_LENGTH]); // Set the P/I/D parameters for a heater
void SetHeaterParameters(GCodeBuffer *gb, char reply[STRING_LENGTH]); // Set the thermistor and ADC parameters for a heater
int8_t Heater(int8_t head) const; // Get the heater number for the specified head
Platform* platform; // The RepRap machine
bool active; // Live and running?
Webserver* webserver; // The webserver class
@ -186,7 +189,7 @@ class GCodes
bool waitingForMoveToComplete;
bool coolingInverted;
float speedFactor; // speed factor, including the conversion from mm/min to mm/sec, normally 1/60
float extrusionFactor; // extrusion factor, normally 1.0
float extrusionFactors[DRIVES - AXES]; // extrusion factors (normally 1.0)
};
//*****************************************************************************************************

View file

@ -57,7 +57,7 @@ Licence: GPL
// Some numbers...
#define STRING_LENGTH 1029 // needs to be long enough to receive web data
#define STRING_LENGTH 1029
#define SHORT_STRING_LENGTH 40
#define TIME_TO_REPRAP 1.0e6 // Convert seconds to the units used by the machine (usually microseconds)
#define TIME_FROM_REPRAP 1.0e-6 // Convert the units used by the machine (usually microseconds) to seconds

Binary file not shown.

View file

@ -486,7 +486,7 @@ bool Webserver::GetJsonResponse(const char* request, const char* key, const char
if (found)
{
snprintf(jsonResponse, ARRAY_UPB(jsonResponse),
"{\"err\":0,\"size\":%lu,\"height\":\"%.2f\",\"filament\":\"%.1f\",\"layerHeight\":\"%.2f\",\"generatedBy\":\"%s\"}",
"{\"err\":0,\"size\":%lu,\"height\":%.2f,\"filament\":%.1f,\"layerHeight\":%.2f,\"generatedBy\":\"%s\"}",
length, height, filament, layerHeight, generatedBy);
}
else
@ -496,7 +496,23 @@ bool Webserver::GetJsonResponse(const char* request, const char* key, const char
}
else if (StringEquals(request, "name"))
{
snprintf(jsonResponse, ARRAY_UPB(jsonResponse), "{\"myName\":\"%s\"}", myName);
snprintf(jsonResponse, ARRAY_UPB(jsonResponse), "{\"myName\":\"");
size_t j = strlen(jsonResponse);
for (size_t i = 0; i < ARRAY_SIZE(myName) - 1; ++i)
{
char c = myName[i];
if (c < ' ') // if null terminator or bad character
break;
if (c == '"' || c == '\\')
{
// Need to escape the quote-mark or backslash for JSON
jsonResponse[j++] = '\\';
}
jsonResponse[j++] = c;
}
jsonResponse[j++] = '"';
jsonResponse[j++] = '}';
jsonResponse[j] = 0;
}
else if (StringEquals(request, "password") && StringEquals(key, "password"))
{
@ -509,7 +525,7 @@ bool Webserver::GetJsonResponse(const char* request, const char* key, const char
char ch = '[';
for (int8_t drive = 0; drive < AXES; drive++)
{
sncatf(jsonResponse, ARRAY_UPB(jsonResponse), "%c\"%.1f\"", ch, platform->AxisTotalLength(drive));
sncatf(jsonResponse, ARRAY_UPB(jsonResponse), "%c%.1f", ch, platform->AxisTotalLength(drive));
ch = ',';
}
strncat(jsonResponse, "]}", ARRAY_UPB(jsonResponse));
@ -547,7 +563,7 @@ void Webserver::GetStatusResponse(uint8_t type)
ch = '[';
for (int8_t heater = 0; heater < HEATERS; heater++)
{
sncatf(jsonResponse, ARRAY_UPB(jsonResponse), "%c\"%.1f\"", ch, reprap.GetHeat()->GetTemperature(heater));
sncatf(jsonResponse, ARRAY_UPB(jsonResponse), "%c\%.1f", ch, reprap.GetHeat()->GetTemperature(heater));
ch = ',';
}
@ -556,21 +572,28 @@ void Webserver::GetStatusResponse(uint8_t type)
reprap.GetMove()->LiveCoordinates(liveCoordinates);
strncat(jsonResponse, "],\"pos\":", ARRAY_UPB(jsonResponse)); // announce the XYZ position
ch = '[';
// We currently provide the extruder 0 value here as well as XYZ. This is only expected by V0.69 and V0.70 of the web interface so it can be removed soon.
for (int8_t drive = 0; drive < AXES + 1; drive++)
//for (int8_t drive = 0; drive < AXES; drive++)
for (int8_t drive = 0; drive < AXES; drive++)
{
sncatf(jsonResponse, ARRAY_UPB(jsonResponse), "%c\"%.2f\"", ch, liveCoordinates[drive]);
sncatf(jsonResponse, ARRAY_UPB(jsonResponse), "%c%.2f", ch, liveCoordinates[drive]);
ch = ',';
}
sncatf(jsonResponse, ARRAY_UPB(jsonResponse), "],\"extr\":"); // announce the extruder positions
ch = '[';
for (int8_t drive = AXES; drive < DRIVES; drive++) // loop through extruders
{
sncatf(jsonResponse, ARRAY_UPB(jsonResponse), "%c\"%.3f\"", ch, gc->GetExtruderPosition(drive - AXES));
sncatf(jsonResponse, ARRAY_UPB(jsonResponse), "%c%.3f", ch, gc->GetExtruderPosition(drive - AXES));
ch = ',';
}
strncat(jsonResponse, "]", ARRAY_UPB(jsonResponse));
// Send the speed and extruder override factors
sncatf(jsonResponse, ARRAY_UPB(jsonResponse), ",\"sfactor\":%.2f,\"efactor:\":", gc->GetSpeedFactor());
const float *extrusionFactors = gc->GetExtrusionFactors();
for (unsigned int i = 0; i < DRIVES - AXES; ++i)
{
sncatf(jsonResponse, ARRAY_UPB(jsonResponse), "%c%.2f", (i == 0) ? '[' : ',', extrusionFactors[i]);
}
strncat(jsonResponse, "]", ARRAY_UPB(jsonResponse));
}
else
{

View file

@ -82,11 +82,11 @@
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
byte alignment -> define MEM_ALIGNMENT to 2. */
#define MEM_ALIGNMENT 4
#define MEM_ALIGNMENT (4)
/* MEM_SIZE: the size of the heap memory. If the application will send
a lot of data that needs to be copied, this should be set high. */
#define MEM_SIZE 3 * 1024
#define MEM_SIZE (3 * 1024)
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
sends a lot of data out of ROM (or other static memory), this