diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-07-27 15:41:59 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-07-27 15:41:59 +0300 |
commit | 448c585f89bb48fcb1b1e728001a0b2f4ca32197 (patch) | |
tree | 966ba3467e6b32cc0ad4f81a45e01e1dffc0d27e /src/GCodes | |
parent | 7abdf8f46f89ca826d27960d65b4e3d23ea32693 (diff) | |
parent | 7fae5e4082a7b5b12b3f89c045440708237f23b7 (diff) |
Merge branch 'v3-chrishamm' into 3.4-dev
Diffstat (limited to 'src/GCodes')
-rw-r--r-- | src/GCodes/GCodes.cpp | 36 | ||||
-rw-r--r-- | src/GCodes/GCodes.h | 11 | ||||
-rw-r--r-- | src/GCodes/GCodes2.cpp | 29 | ||||
-rw-r--r-- | src/GCodes/GCodes3.cpp | 2 | ||||
-rw-r--r-- | src/GCodes/GCodes4.cpp | 3 | ||||
-rw-r--r-- | src/GCodes/ObjectTracker.cpp | 4 | ||||
-rw-r--r-- | src/GCodes/ObjectTracker.h | 2 |
7 files changed, 56 insertions, 31 deletions
diff --git a/src/GCodes/GCodes.cpp b/src/GCodes/GCodes.cpp index ba83e8b8..1a932bd0 100644 --- a/src/GCodes/GCodes.cpp +++ b/src/GCodes/GCodes.cpp @@ -287,6 +287,10 @@ void GCodes::Reset() noexcept #endif doingToolChange = false; doingManualBedProbe = false; +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE + fileOffsetToPrint = 0; + restartMoveFractionDone = 0.0; +#endif #if HAS_LINUX_INTERFACE lastFilePosition = noFilePosition; #endif @@ -1004,7 +1008,7 @@ void GCodes::DoPause(GCodeBuffer& gb, PauseReason reason, const char *msg, uint1 pauseRestorePoint.toolNumber = reprap.GetCurrentToolNumber(); pauseRestorePoint.fanSpeed = lastDefaultFanSpeed; -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE if (simulationMode == 0) { SaveResumeInfo(false); // create the resume file so that we can resume after power down @@ -1175,6 +1179,14 @@ bool GCodes::DoEmergencyPause() noexcept #endif } +#if HAS_LINUX_INTERFACE + if (reprap.UsingLinuxInterface() && pauseRestorePoint.filePos == noFilePosition) + { + // Use the last known print file position if the current one is unknown (e.g. because a macro file is being executed) + pauseRestorePoint.filePos = lastFilePosition; + } +#endif + codeQueue->PurgeEntries(); // Replace the paused machine coordinates by user coordinates, which we updated earlier @@ -1325,16 +1337,10 @@ bool GCodes::ReHomeOnStall(DriversBitmap stalledDrivers) noexcept #endif -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE void GCodes::SaveResumeInfo(bool wasPowerFailure) noexcept { -#if HAS_LINUX_INTERFACE - if (reprap.UsingLinuxInterface()) - { - return; // we can't yet save to the Pi - } -#endif const char* const printingFilename = reprap.GetPrintMonitor().GetPrintingFilename(); if (printingFilename != nullptr) { @@ -3223,8 +3229,6 @@ bool GCodes::QueueFileToPrint(const char* fileName, const StringRef& reply) noex if (f != nullptr) { fileToPrint.Set(f); - fileOffsetToPrint = 0; - restartMoveFractionDone = 0.0; return true; } @@ -3236,6 +3240,9 @@ bool GCodes::QueueFileToPrint(const char* fileName, const StringRef& reply) noex // Start printing the file already selected. We must hold the movement lock and wait for all moves to finish before calling this, because of the call to ResetMoveCounters. void GCodes::StartPrinting(bool fromStart) noexcept { + fileOffsetToPrint = 0; + restartMoveFractionDone = 0.0; + buildObjects.Init(); reprap.GetMove().ResetMoveCounters(); @@ -4174,13 +4181,8 @@ void GCodes::StopPrint(StopPrintReason reason) noexcept platform.MessageF(LoggedGenericMessage, "%s printing file %s, print time was %" PRIu32 "h %" PRIu32 "m\n", (reason == StopPrintReason::normalCompletion) ? "Finished" : "Cancelled", printingFilename, printMinutes/60u, printMinutes % 60u); -#if HAS_MASS_STORAGE - if ( reason == StopPrintReason::normalCompletion - && simulationMode == 0 -# if HAS_LINUX_INTERFACE - && !reprap.UsingLinuxInterface() -# endif - ) +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE + if (reason == StopPrintReason::normalCompletion && simulationMode == 0) { platform.DeleteSysFile(RESUME_AFTER_POWER_FAIL_G); } diff --git a/src/GCodes/GCodes.h b/src/GCodes/GCodes.h index 40d0ca69..d476eb1c 100644 --- a/src/GCodes/GCodes.h +++ b/src/GCodes/GCodes.h @@ -77,11 +77,12 @@ enum class StopPrintReason enum class PauseState : uint8_t { - // Do not change the order of these! We rely on notPaused < pausing < { paused, resuming} + // Do not change the order of these! We rely on notPaused < pausing < { paused, resuming, cancelling } notPaused = 0, pausing, paused, - resuming + resuming, + cancelling }; struct M585Settings @@ -400,7 +401,7 @@ private: #if SUPPORT_WORKPLACE_COORDINATES GCodeResult GetSetWorkplaceCoordinates(GCodeBuffer& gb, const StringRef& reply, bool compute) THROWS(GCodeException); // Set workspace coordinates -# if HAS_MASS_STORAGE +# if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE bool WriteWorkplaceCoordinates(FileStore *f) const noexcept; # endif #endif @@ -482,7 +483,7 @@ private: void EndSimulation(GCodeBuffer *gb) noexcept; // Restore positions etc. when exiting simulation mode bool IsCodeQueueIdle() const noexcept; // Return true if the code queue is idle -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE void SaveResumeInfo(bool wasPowerFailure) noexcept; #endif @@ -597,6 +598,8 @@ private: #if HAS_MASS_STORAGE FileData fileToPrint; // The next file to print +#endif +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE FilePosition fileOffsetToPrint; // The offset to print from #endif diff --git a/src/GCodes/GCodes2.cpp b/src/GCodes/GCodes2.cpp index 742e5575..894630b0 100644 --- a/src/GCodes/GCodes2.cpp +++ b/src/GCodes/GCodes2.cpp @@ -536,6 +536,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx break; } + pauseState = PauseState::cancelling; const bool leaveHeatersOn = (gb.Seen('H') && gb.GetIValue() > 0); gb.SetState((leaveHeatersOn) ? GCodeState::stoppingWithHeatersOn : GCodeState::stoppingWithHeatersOff); (void)DoFileMacro(gb, (code == 0) ? STOP_G : SLEEP_G, false, SystemHelperMacroCode); @@ -905,8 +906,17 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx } } } -#if HAS_MASS_STORAGE - else if (!fileToPrint.IsLive()) +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE + else if ( +# if HAS_MASS_STORAGE + !fileToPrint.IsLive() +# else + true +# endif +# if HAS_LINUX_INTERFACE + && !reprap.UsingLinuxInterface() +# endif + ) { reply.copy("Cannot print, because no file is selected!"); result = GCodeResult::error; @@ -928,7 +938,14 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx // We executed M26 to set the file offset, which normally means that we are executing resurrect.g. // We need to copy the absolute/relative and volumetric extrusion flags over fileGCode->OriginalMachineState().CopyStateFrom(gb.LatestMachineState()); - fileToPrint.Seek(fileOffsetToPrint); +# if HAS_LINUX_INTERFACE + if (!reprap.UsingLinuxInterface()) +# endif +# if HAS_MASS_STORAGE + { + fileToPrint.Seek(fileOffsetToPrint); + } +# endif moveFractionToSkip = restartMoveFractionDone; } StartPrinting(fromStart); @@ -1014,7 +1031,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx } break; -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE case 26: // Set SD position // This is used between executing M23 to set up the file to print, and M25 to print it gb.MustSee('S'); @@ -1028,7 +1045,9 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx restartInitialUserC1 = (gb.Seen(c1)) ? gb.GetFValue() : 0.0; } break; +#endif +#if HAS_MASS_STORAGE case 27: // Report print status - Deprecated if (reprap.GetPrintMonitor().IsPrinting()) { @@ -4409,7 +4428,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx break; #endif -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE case 916: if (!platform.SysFileExists(RESUME_AFTER_POWER_FAIL_G)) { diff --git a/src/GCodes/GCodes3.cpp b/src/GCodes/GCodes3.cpp index b48ae06b..3f991bf0 100644 --- a/src/GCodes/GCodes3.cpp +++ b/src/GCodes/GCodes3.cpp @@ -196,7 +196,7 @@ GCodeResult GCodes::GetSetWorkplaceCoordinates(GCodeBuffer& gb, const StringRef& return GCodeResult::badOrMissingParameter; } -# if HAS_MASS_STORAGE +# if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE // Save all the workplace coordinate offsets to file returning true if successful. Used by M500 and by SaveResumeInfo. bool GCodes::WriteWorkplaceCoordinates(FileStore *f) const noexcept diff --git a/src/GCodes/GCodes4.cpp b/src/GCodes/GCodes4.cpp index ce9cad7e..34a28473 100644 --- a/src/GCodes/GCodes4.cpp +++ b/src/GCodes/GCodes4.cpp @@ -618,6 +618,7 @@ void GCodes::RunStateMachine(GCodeBuffer& gb, const StringRef& reply) noexcept case GCodeState::stoppingWithHeatersOn: // M0 H1 or M1 H1 after executing stop.g/sleep.g if present if (LockMovementAndWaitForStandstill(gb)) { + pauseState = PauseState::notPaused; platform.SetDriversIdle(); gb.SetState(GCodeState::normal); } @@ -1421,7 +1422,7 @@ void GCodes::RunStateMachine(GCodeBuffer& gb, const StringRef& reply) noexcept } else { -# if HAS_MASS_STORAGE +# if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE SaveResumeInfo(true); // create the resume file so that we can resume after power down # endif platform.Message(LoggedGenericMessage, "Print auto-paused due to low voltage\n"); diff --git a/src/GCodes/ObjectTracker.cpp b/src/GCodes/ObjectTracker.cpp index bbd7d70b..fd1af4c1 100644 --- a/src/GCodes/ObjectTracker.cpp +++ b/src/GCodes/ObjectTracker.cpp @@ -265,7 +265,7 @@ void ObjectTracker::ResumePrinting(GCodeBuffer& gb) noexcept } } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE // Write the object details to file, returning true if successful bool ObjectTracker::WriteObjectDirectory(FileStore *f) const noexcept @@ -303,7 +303,7 @@ bool ObjectTracker::WriteObjectDirectory(FileStore *f) const noexcept if (ok) { String<StringLength20> buf; - buf.printf("M486 S%d", currentObjectNumber); + buf.printf("M486 S%d\n", currentObjectNumber); ok = f->Write(buf.c_str()); } diff --git a/src/GCodes/ObjectTracker.h b/src/GCodes/ObjectTracker.h index bb12d5d5..a3b2b098 100644 --- a/src/GCodes/ObjectTracker.h +++ b/src/GCodes/ObjectTracker.h @@ -52,7 +52,7 @@ public: bool IsCancelled(size_t objectNumber) const noexcept { return objectsCancelled.IsBitSet(objectNumber); } #endif -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE bool WriteObjectDirectory(FileStore *f) const noexcept; #endif |