Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2018-04-02 15:46:58 +0300
committerDavid Crocker <dcrocker@eschertech.com>2018-04-02 15:46:58 +0300
commitae14f93f92cc2079802f32aad4cb66998d984674 (patch)
treec5a2370498c0706c5f15ee3a54c9e5986b388b14 /src/Platform.cpp
parent97e7b46202b9f71075101ed86b6967904f87fa98 (diff)
More RTOS work
Got rid of the global scratchString Rationalised some String and StringRef functions Bug fix: if a motor stall triggered a pause, the driver numbers were not listed in the message Fixed possible race conditions in TMC2660 driver,
Diffstat (limited to 'src/Platform.cpp')
-rw-r--r--src/Platform.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/Platform.cpp b/src/Platform.cpp
index 7f391bc6..51ba6de2 100644
--- a/src/Platform.cpp
+++ b/src/Platform.cpp
@@ -1488,12 +1488,12 @@ void Platform::Spin()
// Check for stalled drivers that need to be reported and logged
if (stalledDriversToLog != 0 && reprap.GetGCodes().IsReallyPrinting())
{
- scratchString.Clear();
- ListDrivers(scratchString, stalledDriversToLog);
+ String<ScratchStringLength> scratchString;
+ ListDrivers(scratchString.GetRef(), stalledDriversToLog);
stalledDriversToLog = 0;
float liveCoordinates[DRIVES];
reprap.GetMove().LiveCoordinates(liveCoordinates, reprap.GetCurrentXAxes(), reprap.GetCurrentYAxes());
- MessageF(WarningMessage, "Driver(s)%s stalled at Z height %.2f", scratchString.Pointer(), (double)liveCoordinates[Z_AXIS]);
+ MessageF(WarningMessage, "Driver(s)%s stalled at Z height %.2f", scratchString.c_str(), (double)liveCoordinates[Z_AXIS]);
reported = true;
}
#endif
@@ -1597,6 +1597,7 @@ void Platform::ReportDrivers(MessageType mt, DriversBitmap whichDrivers, const c
{
if (whichDrivers != 0)
{
+ String<ScratchStringLength> scratchString;
scratchString.printf("%s on drivers", text);
for (unsigned int drive = 0; whichDrivers != 0; ++drive)
{
@@ -1606,7 +1607,7 @@ void Platform::ReportDrivers(MessageType mt, DriversBitmap whichDrivers, const c
}
whichDrivers >>= 1;
}
- MessageF(mt, "%s\n", scratchString.Pointer());
+ MessageF(mt, "%s\n", scratchString.c_str());
reported = true;
}
}
@@ -2134,6 +2135,7 @@ void Platform::Diagnostics(MessageType mtype)
: (reason == (uint32_t)SoftwareResetReason::wdtFault) ? "Watchdog timeout"
: (reason == (uint32_t)SoftwareResetReason::otherFault) ? "Other fault"
: "Unknown";
+ String<ScratchStringLength> scratchString;
if (srdBuf[slot].when != 0)
{
const time_t when = (time_t)srdBuf[slot].when;
@@ -2147,7 +2149,7 @@ void Platform::Diagnostics(MessageType mtype)
}
MessageF(mtype, "Last software reset %s, reason: %s%s, spinning module %s, available RAM %" PRIu32 " bytes (slot %d)\n",
- scratchString.Pointer(),
+ scratchString.c_str(),
(srdBuf[slot].resetReason & (uint32_t)SoftwareResetReason::deliberate) ? "deliberate " : "",
reasonText, moduleName[srdBuf[slot].resetReason & 0x0F], srdBuf[slot].neverUsedRam, slot);
// Our format buffer is only 256 characters long, so the next 2 lines must be written separately
@@ -2161,7 +2163,7 @@ void Platform::Diagnostics(MessageType mtype)
{
scratchString.catf(" %08" PRIx32, srdBuf[slot].stack[i]);
}
- MessageF(mtype, "Stack:%s\n", scratchString.Pointer());
+ MessageF(mtype, "Stack:%s\n", scratchString.c_str());
}
}
else
@@ -2742,6 +2744,7 @@ bool Platform::WriteAxisLimits(FileStore *f, AxesBitmap axesProbed, const float
return true;
}
+ String<ScratchStringLength> scratchString;
scratchString.printf("M208 S%d", sParam);
for (size_t axis = 0; axis < MaxAxes; ++axis)
{
@@ -2751,7 +2754,7 @@ bool Platform::WriteAxisLimits(FileStore *f, AxesBitmap axesProbed, const float
}
}
scratchString.cat('\n');
- return f->Write(scratchString.Pointer());
+ return f->Write(scratchString.c_str());
}
// This is called from the step ISR as well as other places, so keep it fast
@@ -3576,16 +3579,16 @@ void Platform::MessageF(MessageType type, const char *fmt, va_list vargs)
if ((type & ErrorMessageFlag) != 0)
{
formatString.copy("Error: ");
- formatString.GetRef().vcatf(fmt, vargs);
+ formatString.vcatf(fmt, vargs);
}
else if ((type & WarningMessageFlag) != 0)
{
formatString.copy("Warning: ");
- formatString.GetRef().vcatf(fmt, vargs);
+ formatString.vcatf(fmt, vargs);
}
else
{
- formatString.GetRef().vprintf(fmt, vargs);
+ formatString.vprintf(fmt, vargs);
}
RawMessage((MessageType)(type & ~(ErrorMessageFlag | WarningMessageFlag)), formatString.c_str());