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:
authorChristian Hammacher <bmasterc@gmail.com>2021-10-04 23:12:23 +0300
committerChristian Hammacher <bmasterc@gmail.com>2021-10-04 23:12:23 +0300
commit82934c253fb8b3578620b19fe047683f41734521 (patch)
treed585600f8c740ec7cc118febfe2524449f712ec2 /src/GCodes
parent1cbc804408f7efb198c388dd8d5af1d08c8fbf20 (diff)
Work towards v3.4-b5
RRF writes config-override.g in SBC mode Bug fix: Invalid file position could be sent to DSF on pause
Diffstat (limited to 'src/GCodes')
-rw-r--r--src/GCodes/GCodes.cpp37
-rw-r--r--src/GCodes/GCodes.h3
-rw-r--r--src/GCodes/GCodes2.cpp4
3 files changed, 30 insertions, 14 deletions
diff --git a/src/GCodes/GCodes.cpp b/src/GCodes/GCodes.cpp
index 72c6aff5..9b505e24 100644
--- a/src/GCodes/GCodes.cpp
+++ b/src/GCodes/GCodes.cpp
@@ -340,7 +340,7 @@ bool GCodes::WaitingForAcknowledgement() const noexcept
// Return the current position of the file being printed in bytes.
// Unlike other methods returning file positions it never returns noFilePosition
-FilePosition GCodes::GetPrintingFilePosition() const noexcept
+FilePosition GCodes::GetFilePosition() const noexcept
{
#if HAS_LINUX_INTERFACE
if (!reprap.UsingLinuxInterface())
@@ -350,22 +350,27 @@ FilePosition GCodes::GetPrintingFilePosition() const noexcept
const FileData& fileBeingPrinted = fileGCode->OriginalMachineState().fileState;
if (!fileBeingPrinted.IsLive())
{
- return 0;
+ return noFilePosition;
}
#endif
}
#if HAS_MASS_STORAGE || HAS_EMBEDDED_FILES || HAS_LINUX_INTERFACE
- const FilePosition pos = (fileGCode->IsDoingFileMacro())
+ return (fileGCode->IsDoingFileMacro())
? printFilePositionAtMacroStart // the position before we started executing the macro
: fileGCode->GetFilePosition(); // the actual position, allowing for bytes cached but not yet processed
-
- return (pos == noFilePosition) ? 0 : pos;
#else
- return 0;
+ return noFilePosition;
#endif
}
+// Return the current position of the file being printed in bytes or noFilePosition if unknown
+FilePosition GCodes::GetPrintingFilePosition() const noexcept
+{
+ const FilePosition pos = GetFilePosition();
+ return (pos != noFilePosition) ? pos : 0;
+}
+
// Start running the config file
bool GCodes::RunConfigFile(const char* fileName) noexcept
{
@@ -928,8 +933,8 @@ void GCodes::DoPause(GCodeBuffer& gb, PauseReason reason, const char *msg, uint1
// TODO: when using RTOS there is a possible race condition in the following,
// because we might try to pause when a waiting move has just been added but before the gcode buffer has been re-initialised ready for the next command
- pauseRestorePoint.filePos = GetPrintingFilePosition();
- while (fileGCode->IsDoingFileMacro()) // must call this after GetPrintingFilePosition because it changes IsDoingFileMacro
+ pauseRestorePoint.filePos = GetFilePosition();
+ while (fileGCode->IsDoingFileMacro()) // must call this after GetFilePosition because this changes IsDoingFileMacro
{
pausedInMacro = true;
fileGCode->PopState();
@@ -1057,11 +1062,16 @@ void GCodes::DoPause(GCodeBuffer& gb, PauseReason reason, const char *msg, uint1
}
// Prepare notification for the Linux side
- FilePosition reportedFilePosition = pausedInMacro ? printFilePositionAtMacroStart : gb.GetFilePosition();
- reprap.GetLinuxInterface().SetPauseReason(reportedFilePosition, pauseReason);
+ reprap.GetLinuxInterface().SetPauseReason(pauseRestorePoint.filePos, pauseReason);
}
#endif
+ if (pauseRestorePoint.filePos == noFilePosition)
+ {
+ // Make sure we expose usable values (which noFilePosition is not)
+ pauseRestorePoint.filePos = 0;
+ }
+
if (msg != nullptr)
{
platform.SendAlert(GenericMessage, msg, "Printing paused", 1, 0.0, AxesBitmap());
@@ -1152,7 +1162,7 @@ bool GCodes::DoEmergencyPause() noexcept
pauseRestorePoint.feedRate = fileGCode->LatestMachineState().feedRate;
pauseRestorePoint.virtualExtruderPosition = virtualExtruderPosition;
- pauseRestorePoint.filePos = GetPrintingFilePosition();
+ pauseRestorePoint.filePos = GetFilePosition();
pauseRestorePoint.proportionDone = 0.0;
#if SUPPORT_LASER || SUPPORT_IOBITS
@@ -1176,6 +1186,11 @@ bool GCodes::DoEmergencyPause() noexcept
pauseRestorePoint.moveCoords[axis] = moveState.currentUserPosition[axis];
}
+ if (pauseRestorePoint.filePos == noFilePosition)
+ {
+ // Make sure we expose usable values (which noFilePosition is not)
+ pauseRestorePoint.filePos = 0;
+ }
pauseRestorePoint.toolNumber = reprap.GetCurrentToolNumber();
pauseRestorePoint.fanSpeed = lastDefaultFanSpeed;
pauseState = PauseState::paused;
diff --git a/src/GCodes/GCodes.h b/src/GCodes/GCodes.h
index 21796b31..7b720ba6 100644
--- a/src/GCodes/GCodes.h
+++ b/src/GCodes/GCodes.h
@@ -133,7 +133,8 @@ public:
bool GetMacroRestarted() const noexcept; // Return true if the macro being executed by fileGCode was restarted
bool WaitingForAcknowledgement() const noexcept; // Is an input waiting for a message to be acknowledged?
- FilePosition GetPrintingFilePosition() const noexcept; // Return the current position of the file being printed in bytes
+ FilePosition GetFilePosition() const noexcept; // Return the current position of the file being printed in bytes
+ FilePosition GetPrintingFilePosition() const noexcept; // Return a valid position of the file being printed in bytes
void Diagnostics(MessageType mtype) noexcept; // Send helpful information out
bool RunConfigFile(const char* fileName) noexcept; // Start running the config file
diff --git a/src/GCodes/GCodes2.cpp b/src/GCodes/GCodes2.cpp
index d5cc607b..0b5ed433 100644
--- a/src/GCodes/GCodes2.cpp
+++ b/src/GCodes/GCodes2.cpp
@@ -470,7 +470,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx
|| code == 112
|| code == 374 || code == 375
|| code == 470 || code == 471
- || code == 500 || code == 503 || code == 505
+ || code == 503 || code == 505
|| code == 540 || code == 550 || code == 552 || code == 586 || (code >= 587 && code <= 589)
|| code == 703
|| code == 905 || code == 929 || code == 997 || code == 999
@@ -2977,7 +2977,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx
result = buildObjects.HandleM486(gb, reply, outBuf);
break;
-#if HAS_MASS_STORAGE
+#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE
case 500: // Store parameters in config-override.g
result = WriteConfigOverrideFile(gb, reply);
break;