diff options
author | David Crocker <dcrocker@eschertech.com> | 2022-02-24 21:57:23 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2022-02-24 21:57:23 +0300 |
commit | ebe9a404909053f2228f98068678b20ac45bfc34 (patch) | |
tree | dcaafd3b31ba1baa2064e9f270d6ed780cb63e08 /src | |
parent | 8dc25dd017e091c093be4ec320d15959f50977bf (diff) |
Fix for M291 in homing file
Diffstat (limited to 'src')
-rw-r--r-- | src/GCodes/GCodeMachineState.h | 2 | ||||
-rw-r--r-- | src/GCodes/GCodes.cpp | 20 | ||||
-rw-r--r-- | src/GCodes/GCodes2.cpp | 2 | ||||
-rw-r--r-- | src/GCodes/GCodes4.cpp | 4 | ||||
-rw-r--r-- | src/Version.h | 2 |
5 files changed, 11 insertions, 19 deletions
diff --git a/src/GCodes/GCodeMachineState.h b/src/GCodes/GCodeMachineState.h index 8a5b374a..d5b74a73 100644 --- a/src/GCodes/GCodeMachineState.h +++ b/src/GCodes/GCodeMachineState.h @@ -206,6 +206,8 @@ public: #if HAS_SBC_INTERFACE FileId fileId; // virtual ID to distinguish files in different stack levels (only unique per GB) #endif + // Note, having a bit set in lockedResources doesn't necessarily mean that we own the lock! + // It means we acquired the lock at this stack level, and haven't released it at this level. It may have been released at a more nested level, or stolen from us (see GrabResource). ResourceBitmap lockedResources; BlockState blockStates[MaxBlockIndent]; uint32_t lineNumber; diff --git a/src/GCodes/GCodes.cpp b/src/GCodes/GCodes.cpp index dbc2401f..cc0f34cf 100644 --- a/src/GCodes/GCodes.cpp +++ b/src/GCodes/GCodes.cpp @@ -4627,17 +4627,9 @@ void GCodes::GrabResource(const GCodeBuffer& gb, Resource r) noexcept if (resourceOwners[r] != &gb) { - if (resourceOwners[r] != nullptr) - { - GCodeMachineState *m = &(resourceOwners[r]->LatestMachineState()); - do - { - m->lockedResources.ClearBit(r); - m = m->GetPrevious(); - } - while (m != nullptr); - } + // Note, we now leave the resource bit set in the original owning GCodeBuffer machine state resourceOwners[r] = &gb; + gb.LatestMachineState().lockedResources.SetBit(r); } } @@ -4672,12 +4664,8 @@ void GCodes::UnlockResource(const GCodeBuffer& gb, Resource r) noexcept if (resourceOwners[r] == &gb) { - GCodeMachineState * mc = &gb.LatestMachineState(); - do - { - mc->lockedResources.ClearBit(r); - mc = mc->GetPrevious(); - } while (mc != nullptr); + // Note, we leave the bit set in previous stack levels! This is needed e.g. to allow M291 blocking messages to be used in homing files. + gb.LatestMachineState().lockedResources.ClearBit(r); resourceOwners[r] = nullptr; } } diff --git a/src/GCodes/GCodes2.cpp b/src/GCodes/GCodes2.cpp index 158b8a59..62f441c2 100644 --- a/src/GCodes/GCodes2.cpp +++ b/src/GCodes/GCodes2.cpp @@ -1517,7 +1517,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx // 2020-02-04 Don't unlock movement if it was already locked, e.g. because M109 was used in a macro if (!movementWasLocked) { - UnlockMovement(gb); // allow babystepping and pausing while heating + UnlockMovement(gb); // allow babystepping and pausing while heating } } diff --git a/src/GCodes/GCodes4.cpp b/src/GCodes/GCodes4.cpp index 1170bcc3..28844f04 100644 --- a/src/GCodes/GCodes4.cpp +++ b/src/GCodes/GCodes4.cpp @@ -269,6 +269,7 @@ void GCodes::RunStateMachine(GCodeBuffer& gb, const StringRef& reply) noexcept break; case GCodeState::homing1: + // We should only ever get here when toBeHomed is not empty if (toBeHomed.IsEmpty()) { gb.SetState(GCodeState::normal); @@ -309,7 +310,8 @@ void GCodes::RunStateMachine(GCodeBuffer& gb, const StringRef& reply) noexcept // Test whether the previous homing move homed any axes if (toBeHomed.Disjoint(axesHomed)) { - reply.copy("Homing failed"); + reply.copy("Failed to home axes "); + AppendAxes(reply, toBeHomed); stateMachineResult = GCodeResult::error; toBeHomed.Clear(); gb.SetState(GCodeState::normal); diff --git a/src/Version.h b/src/Version.h index 044430ad..53b2d577 100644 --- a/src/Version.h +++ b/src/Version.h @@ -10,7 +10,7 @@ #ifndef VERSION // Note: the complete VERSION string must be in standard version number format and must not contain spaces! This is so that DWC can parse it. -# define MAIN_VERSION "3.4.0rc2" +# define MAIN_VERSION "3.4.0rc2+1" # ifdef USE_CAN0 # define VERSION_SUFFIX "(CAN0)" # else |