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>2022-11-10 15:41:22 +0300
committerDavid Crocker <dcrocker@eschertech.com>2022-11-10 15:41:22 +0300
commit785a7923e628f7a5699c2f52b277b3dbda8ed7f6 (patch)
treec4e306fe7f7d2ec86adb1d540f412a51f3b80259
parentcb805a0a4f6638d43a2d8e5bb2803a74d72c56c9 (diff)
Correction to previous fix
-rw-r--r--src/GCodes/GCodeBuffer/GCodeBuffer.cpp13
-rw-r--r--src/GCodes/GCodeBuffer/GCodeBuffer.h1
-rw-r--r--src/GCodes/GCodes.cpp3
-rw-r--r--src/Platform/Platform.cpp2
-rw-r--r--src/RepRapFirmware.cpp4
-rw-r--r--src/RepRapFirmware.h2
6 files changed, 19 insertions, 6 deletions
diff --git a/src/GCodes/GCodeBuffer/GCodeBuffer.cpp b/src/GCodes/GCodeBuffer/GCodeBuffer.cpp
index 62b64e19..17ece53e 100644
--- a/src/GCodes/GCodeBuffer/GCodeBuffer.cpp
+++ b/src/GCodes/GCodeBuffer/GCodeBuffer.cpp
@@ -859,6 +859,19 @@ GCodeMachineState& GCodeBuffer::CurrentFileMachineState() const noexcept
return *ms;
}
+// Return true if all GCodes machine states on the stack are 'normal'
+bool GCodeBuffer::AllStatesNormal() const noexcept
+{
+ for (const GCodeMachineState *ms = machineState; ms != nullptr; ms = ms->GetPrevious())
+ {
+ if (ms->GetState() != GCodeState::normal)
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
// Convert from inches to mm if necessary
float GCodeBuffer::ConvertDistance(float distance) const noexcept
{
diff --git a/src/GCodes/GCodeBuffer/GCodeBuffer.h b/src/GCodes/GCodeBuffer/GCodeBuffer.h
index d18685cb..3b70d8e1 100644
--- a/src/GCodes/GCodeBuffer/GCodeBuffer.h
+++ b/src/GCodes/GCodeBuffer/GCodeBuffer.h
@@ -161,6 +161,7 @@ public:
GCodeMachineState& OriginalMachineState() const noexcept;
GCodeMachineState::BlockState& GetBlockState() const noexcept { return CurrentFileMachineState().CurrentBlockState(); }
uint16_t GetBlockIndent() const noexcept { return GetBlockState().GetIndent(); }
+ bool AllStatesNormal() const noexcept; // Return true if all GCode states on the stack are 'normal'
void UseInches(bool inchesNotMm) noexcept { machineState->usingInches = inchesNotMm; }
bool UsingInches() const noexcept { return machineState->usingInches; }
diff --git a/src/GCodes/GCodes.cpp b/src/GCodes/GCodes.cpp
index f0adca78..6164c029 100644
--- a/src/GCodes/GCodes.cpp
+++ b/src/GCodes/GCodes.cpp
@@ -1605,8 +1605,7 @@ bool GCodes::LockMovementSystemAndWaitForStandstill(GCodeBuffer& gb, unsigned in
collisionChecker.ResetPositions(ms.coords, ms.GetAxesAndExtrudersOwned());
// Release the axes and extruders that this movement system owns, except those used by the current tool
- // Don't release them if we are in the middle of a state machine operation e.g. probing the bed
- if (gb.GetState() == GCodeState::normal)
+ if (gb.AllStatesNormal()) // don't release them if we are in the middle of a state machine operation e.g. probing the bed
{
if (ms.currentTool != nullptr)
{
diff --git a/src/Platform/Platform.cpp b/src/Platform/Platform.cpp
index 72ebaa4f..0f68d70f 100644
--- a/src/Platform/Platform.cpp
+++ b/src/Platform/Platform.cpp
@@ -1149,7 +1149,7 @@ void Platform::Spin() noexcept
{
if (timer.IsRunning())
{
- if (!timer.Check(OpenLoadTimeout))
+ if (!timer.CheckNoStop(OpenLoadTimeout))
{
stat.ClearOpenLoadBits();
}
diff --git a/src/RepRapFirmware.cpp b/src/RepRapFirmware.cpp
index 478bebaa..509a0fcb 100644
--- a/src/RepRapFirmware.cpp
+++ b/src/RepRapFirmware.cpp
@@ -228,7 +228,7 @@ void MillisTimer::Start() noexcept
}
// Check whether the timer is running and a timeout has expired, but don't stop it
-bool MillisTimer::Check(uint32_t timeoutMillis) const noexcept
+bool MillisTimer::CheckNoStop(uint32_t timeoutMillis) const noexcept
{
return running && millis() - whenStarted >= timeoutMillis;
}
@@ -236,7 +236,7 @@ bool MillisTimer::Check(uint32_t timeoutMillis) const noexcept
// Check whether a timeout has expired and stop the timer if it has, else leave it running if it was running
bool MillisTimer::CheckAndStop(uint32_t timeoutMillis) noexcept
{
- const bool ret = Check(timeoutMillis);
+ const bool ret = CheckNoStop(timeoutMillis);
if (ret)
{
running = false;
diff --git a/src/RepRapFirmware.h b/src/RepRapFirmware.h
index 2c0133f4..6264a5f2 100644
--- a/src/RepRapFirmware.h
+++ b/src/RepRapFirmware.h
@@ -462,7 +462,7 @@ public:
MillisTimer() noexcept { running = false; }
void Start() noexcept;
void Stop() noexcept { running = false; }
- bool Check(uint32_t timeoutMillis) const noexcept;
+ bool CheckNoStop(uint32_t timeoutMillis) const noexcept;
bool CheckAndStop(uint32_t timeoutMillis) noexcept;
bool IsRunning() const noexcept { return running; }