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 | |
parent | 7abdf8f46f89ca826d27960d65b4e3d23ea32693 (diff) | |
parent | 7fae5e4082a7b5b12b3f89c045440708237f23b7 (diff) |
Merge branch 'v3-chrishamm' into 3.4-dev
35 files changed, 112 insertions, 85 deletions
diff --git a/src/Fans/Fan.cpp b/src/Fans/Fan.cpp index 97f7c501..aae2e6fc 100644 --- a/src/Fans/Fan.cpp +++ b/src/Fans/Fan.cpp @@ -194,7 +194,7 @@ GCodeResult Fan::SetPwm(float speed, const StringRef& reply) noexcept return Refresh(reply); } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE // Save the settings of this fan if it isn't thermostatic bool Fan::WriteSettings(FileStore *f, size_t fanNum) const noexcept diff --git a/src/Fans/Fan.h b/src/Fans/Fan.h index 691166da..52ed20b5 100644 --- a/src/Fans/Fan.h +++ b/src/Fans/Fan.h @@ -48,7 +48,7 @@ public: bool HasMonitoredSensors() const noexcept { return sensorsMonitored.IsNonEmpty(); } const char *GetName() const noexcept { return name.c_str(); } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE bool WriteSettings(FileStore *f, size_t fanNum) const noexcept; // save the settings of this fan if it isn't thermostatic #endif diff --git a/src/Fans/FansManager.cpp b/src/Fans/FansManager.cpp index 12cd572b..75ecc3e2 100644 --- a/src/Fans/FansManager.cpp +++ b/src/Fans/FansManager.cpp @@ -75,7 +75,7 @@ size_t FansManager::GetNumFansToReport() const noexcept return numFans; } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE bool FansManager::WriteFanSettings(FileStore *f) const noexcept { diff --git a/src/Fans/FansManager.h b/src/Fans/FansManager.h index 309e62b3..bd9d7589 100644 --- a/src/Fans/FansManager.h +++ b/src/Fans/FansManager.h @@ -41,7 +41,7 @@ public: #if SUPPORT_CAN_EXPANSION void ProcessRemoteFanRpms(CanAddress src, const CanMessageFansReport& msg) noexcept; #endif -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE bool WriteFanSettings(FileStore *f) const noexcept; #endif 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 diff --git a/src/Heating/FOPDT.cpp b/src/Heating/FOPDT.cpp index 3ffee68d..a4021864 100644 --- a/src/Heating/FOPDT.cpp +++ b/src/Heating/FOPDT.cpp @@ -7,7 +7,7 @@ #include "FOPDT.h" -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE # include "Storage/FileStore.h" #endif @@ -146,7 +146,7 @@ void FopDt::SetM301PidParameters(const M301PidParameters& pp) noexcept pidParametersOverridden = true; } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE // Write the model parameters to file returning true if no error bool FopDt::WriteParameters(FileStore *f, size_t heater) const noexcept diff --git a/src/Heating/FOPDT.h b/src/Heating/FOPDT.h index 84ac8123..7edee12a 100644 --- a/src/Heating/FOPDT.h +++ b/src/Heating/FOPDT.h @@ -72,7 +72,7 @@ public: return (forLoadChange) ? loadChangeParams : setpointChangeParams; } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE bool WriteParameters(FileStore *f, size_t heater) const noexcept; // erite the model parameters to file returning true if no error #endif diff --git a/src/Heating/Heat.cpp b/src/Heating/Heat.cpp index fe5c1ef4..a7ec0ac9 100644 --- a/src/Heating/Heat.cpp +++ b/src/Heating/Heat.cpp @@ -730,7 +730,7 @@ float Heat::GetHighestTemperatureLimit() const noexcept return limit; } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE // Write heater model parameters to file returning true if no error bool Heat::WriteModelParameters(FileStore *f) const noexcept @@ -1096,7 +1096,7 @@ void Heat::InsertSensor(TemperatureSensor *newSensor) noexcept } } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE // Save some resume information returning true if successful. // We assume that the bed and chamber heaters are either on and active, or off (not on standby). diff --git a/src/Heating/Heat.h b/src/Heating/Heat.h index 2b13ca3a..7402eae2 100644 --- a/src/Heating/Heat.h +++ b/src/Heating/Heat.h @@ -128,7 +128,7 @@ public: void SwitchOff(int heater) noexcept; // Turn off a specific heater void FeedForwardAdjustment(unsigned int heater, float fanPwmChange, float extrusionChange) const noexcept; -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE bool WriteModelParameters(FileStore *f) const noexcept; // Write heater model parameters to file returning true if no error bool WriteBedAndChamberTempSettings(FileStore *f) const noexcept; // Save some resume information #endif diff --git a/src/Linux/DataTransfer.cpp b/src/Linux/DataTransfer.cpp index 84e0d966..69c09cd9 100644 --- a/src/Linux/DataTransfer.cpp +++ b/src/Linux/DataTransfer.cpp @@ -1576,13 +1576,18 @@ bool DataTransfer::WriteCheckFileExists(const char *filename) noexcept { // Check if it fits size_t filenameLength = strlen(filename); - if (!CanWritePacket(filenameLength)) + if (!CanWritePacket(sizeof(StringHeader) + filenameLength)) { return false; } // Write packet header - (void)WritePacketHeader(FirmwareRequest::CheckFileExists, filenameLength); + (void)WritePacketHeader(FirmwareRequest::CheckFileExists, sizeof(StringHeader) + filenameLength); + + // Write header + StringHeader *header = WriteDataHeader<StringHeader>(); + header->length = filenameLength; + header->padding = 0; // Write filename WriteData(filename, filenameLength); diff --git a/src/Linux/LinuxInterface.cpp b/src/Linux/LinuxInterface.cpp index 7a50ec41..c442ffa5 100644 --- a/src/Linux/LinuxInterface.cpp +++ b/src/Linux/LinuxInterface.cpp @@ -274,8 +274,8 @@ void LinuxInterface::Spin() noexcept break; } - // Print has been started, set file print info - case LinuxRequest::PrintStarted: + // Print is about to be started, set file print info + case LinuxRequest::SetPrintFileInfo: { String<MaxFilenameLength> filename; transfer.ReadPrintStartedInfo(packet->length, filename.GetRef(), fileInfo); diff --git a/src/Linux/LinuxMessageFormats.h b/src/Linux/LinuxMessageFormats.h index 9716b602..82c645bf 100644 --- a/src/Linux/LinuxMessageFormats.h +++ b/src/Linux/LinuxMessageFormats.h @@ -249,7 +249,7 @@ enum class LinuxRequest : uint16_t Code = 2, // Request execution of a G/M/T-code GetObjectModel = 3, // Request a part of the machine's object model SetObjectModel = 4, // Set a value in the machine's object model - PrintStarted = 5, // Print has been started, set file print information + SetPrintFileInfo = 5, // Print is about to be started, set file print information PrintStopped = 6, // Print has been stopped, reset file print information MacroCompleted = 7, // Notification that a macro file has been fully processed GetHeightMap = 8, // Request the heightmap coordinates as generated by G29 S0 diff --git a/src/Movement/Kinematics/HangprinterKinematics.cpp b/src/Movement/Kinematics/HangprinterKinematics.cpp index 3d5c65aa..11083cee 100644 --- a/src/Movement/Kinematics/HangprinterKinematics.cpp +++ b/src/Movement/Kinematics/HangprinterKinematics.cpp @@ -435,7 +435,7 @@ AxesBitmap HangprinterKinematics::MustBeHomedAxes(AxesBitmap axesMoving, bool di return axesMoving; } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE // Write the parameters that are set by auto calibration to a file, returning true if success bool HangprinterKinematics::WriteCalibrationParameters(FileStore *f) const noexcept diff --git a/src/Movement/Kinematics/HangprinterKinematics.h b/src/Movement/Kinematics/HangprinterKinematics.h index 9258745c..c974c2fe 100644 --- a/src/Movement/Kinematics/HangprinterKinematics.h +++ b/src/Movement/Kinematics/HangprinterKinematics.h @@ -24,7 +24,7 @@ public: bool SupportsAutoCalibration() const noexcept override { return true; } bool DoAutoCalibration(size_t numFactors, const RandomProbePointSet& probePoints, const StringRef& reply) noexcept override; void SetCalibrationDefaults() noexcept override { Init(); } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE bool WriteCalibrationParameters(FileStore *f) const noexcept override; #endif LimitPositionResult LimitPosition(float finalCoords[], const float * null initialCoords, size_t numAxes, AxesBitmap axesToLimit, bool isCoordinated, bool applyM208Limits) const noexcept override; @@ -37,7 +37,7 @@ public: AxesBitmap GetHomingFileName(AxesBitmap toBeHomed, AxesBitmap alreadyHomed, size_t numVisibleAxes, const StringRef& filename) const noexcept override; bool QueryTerminateHomingMove(size_t axis) const noexcept override; void OnHomingSwitchTriggered(size_t axis, bool highEnd, const float stepsPerMm[], DDA& dda) const noexcept override; -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE bool WriteResumeSettings(FileStore *f) const noexcept override; #endif diff --git a/src/Movement/Kinematics/Kinematics.h b/src/Movement/Kinematics/Kinematics.h index addd6098..6b1eaae1 100644 --- a/src/Movement/Kinematics/Kinematics.h +++ b/src/Movement/Kinematics/Kinematics.h @@ -124,7 +124,7 @@ public: // Do nothing if auto calibration is not supported. virtual void SetCalibrationDefaults() noexcept { } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE // Write the parameters that are set by auto calibration to the config-override.g file, returning true if success // Just return true if auto calibration is not supported. virtual bool WriteCalibrationParameters(FileStore *f) const noexcept { return true; } @@ -186,7 +186,7 @@ public: // This default is good for Cartesian and Core printers, but not deltas or SCARA virtual AxesBitmap MustBeHomedAxes(AxesBitmap axesMoving, bool disallowMovesBeforeHoming) const noexcept { return (disallowMovesBeforeHoming) ? axesMoving : AxesBitmap(); } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE // Write any calibration data that we need to resume a print after power fail, returning true if successful. Override where necessary. virtual bool WriteResumeSettings(FileStore *f) const noexcept { return true; } #endif diff --git a/src/Movement/Kinematics/LinearDeltaKinematics.cpp b/src/Movement/Kinematics/LinearDeltaKinematics.cpp index 7328294c..e504f31e 100644 --- a/src/Movement/Kinematics/LinearDeltaKinematics.cpp +++ b/src/Movement/Kinematics/LinearDeltaKinematics.cpp @@ -785,7 +785,7 @@ void LinearDeltaKinematics::PrintParameters(const StringRef& reply) const noexce (double)(xTilt * 100.0), (double)(yTilt * 100.0)); } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE // Write the parameters that are set by auto calibration to a file, returning true if success bool LinearDeltaKinematics::WriteCalibrationParameters(FileStore *f) const noexcept @@ -814,6 +814,7 @@ bool LinearDeltaKinematics::WriteCalibrationParameters(FileStore *f) const noexc return ok; } + // Write any calibration data that we need to resume a print after power fail, returning true if successful bool LinearDeltaKinematics::WriteResumeSettings(FileStore *f) const noexcept { diff --git a/src/Movement/Kinematics/LinearDeltaKinematics.h b/src/Movement/Kinematics/LinearDeltaKinematics.h index bdc008cf..d0e9cdcd 100644 --- a/src/Movement/Kinematics/LinearDeltaKinematics.h +++ b/src/Movement/Kinematics/LinearDeltaKinematics.h @@ -27,7 +27,7 @@ public: bool DoAutoCalibration(size_t numFactors, const RandomProbePointSet& probePoints, const StringRef& reply) noexcept override; void SetCalibrationDefaults() noexcept override { Init(); } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE bool WriteCalibrationParameters(FileStore *f) const noexcept override; #endif @@ -44,7 +44,7 @@ public: bool QueryTerminateHomingMove(size_t axis) const noexcept override; void OnHomingSwitchTriggered(size_t axis, bool highEnd, const float stepsPerMm[], DDA& dda) const noexcept override; -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE bool WriteResumeSettings(FileStore *f) const noexcept override; #endif diff --git a/src/Movement/Kinematics/RotaryDeltaKinematics.cpp b/src/Movement/Kinematics/RotaryDeltaKinematics.cpp index 53d15d47..595304a0 100644 --- a/src/Movement/Kinematics/RotaryDeltaKinematics.cpp +++ b/src/Movement/Kinematics/RotaryDeltaKinematics.cpp @@ -560,7 +560,7 @@ void RotaryDeltaKinematics::PrintParameters(const StringRef& reply) const noexce (double)angleCorrections[DELTA_A_AXIS], (double)angleCorrections[DELTA_B_AXIS], (double)angleCorrections[DELTA_C_AXIS]); } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE // Add a space, character, and 3-element vector to the string static void CatVector3(const StringRef& str, char c, const float vec[3]) noexcept diff --git a/src/Movement/Kinematics/RotaryDeltaKinematics.h b/src/Movement/Kinematics/RotaryDeltaKinematics.h index 1ff6bef2..807e301c 100644 --- a/src/Movement/Kinematics/RotaryDeltaKinematics.h +++ b/src/Movement/Kinematics/RotaryDeltaKinematics.h @@ -24,7 +24,7 @@ public: bool SupportsAutoCalibration() const noexcept override { return true; } bool DoAutoCalibration(size_t numFactors, const RandomProbePointSet& probePoints, const StringRef& reply) noexcept override; void SetCalibrationDefaults() noexcept override { Init(); } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE bool WriteCalibrationParameters(FileStore *f) const noexcept override; #endif LimitPositionResult LimitPosition(float finalCoords[], const float * null initialCoords, size_t numVisibleAxes, AxesBitmap axesToLimit, bool isCoordinated, bool applyM208Limits) const noexcept override; @@ -37,7 +37,7 @@ public: AxesBitmap GetHomingFileName(AxesBitmap toBeHomed, AxesBitmap alreadyHomed, size_t numVisibleAxes, const StringRef& filename) const noexcept override; bool QueryTerminateHomingMove(size_t axis) const noexcept override; void OnHomingSwitchTriggered(size_t axis, bool highEnd, const float stepsPerMm[], DDA& dda) const noexcept override; -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE bool WriteResumeSettings(FileStore *f) const noexcept override; #endif diff --git a/src/Movement/Kinematics/ZLeadscrewKinematics.cpp b/src/Movement/Kinematics/ZLeadscrewKinematics.cpp index 61293b5c..63c2201c 100644 --- a/src/Movement/Kinematics/ZLeadscrewKinematics.cpp +++ b/src/Movement/Kinematics/ZLeadscrewKinematics.cpp @@ -421,7 +421,7 @@ void ZLeadscrewKinematics::AppendCorrections(const floatc_t corrections[], const } } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE // Write any calibration data that we need to resume a print after power fail, returning true if successful bool ZLeadscrewKinematics::WriteResumeSettings(FileStore *f) const noexcept diff --git a/src/Movement/Kinematics/ZLeadscrewKinematics.h b/src/Movement/Kinematics/ZLeadscrewKinematics.h index 5c8d0834..75d2a489 100644 --- a/src/Movement/Kinematics/ZLeadscrewKinematics.h +++ b/src/Movement/Kinematics/ZLeadscrewKinematics.h @@ -20,7 +20,7 @@ public: bool Configure(unsigned int mCode, GCodeBuffer& gb, const StringRef& reply, bool& error) THROWS(GCodeException) override; bool SupportsAutoCalibration() const noexcept override; bool DoAutoCalibration(size_t numFactors, const RandomProbePointSet& probePoints, const StringRef& reply) noexcept override; -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE bool WriteResumeSettings(FileStore *f) const noexcept override; #endif diff --git a/src/Movement/Move.cpp b/src/Movement/Move.cpp index 41b26b2b..b6fae1fa 100644 --- a/src/Movement/Move.cpp +++ b/src/Movement/Move.cpp @@ -953,7 +953,7 @@ void Move::SetIdleTimeout(float timeout) noexcept reprap.MoveUpdated(); } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE // Write settings for resuming the print // The GCodes module deals with the head position so all we need worry about is the bed compensation diff --git a/src/Movement/Move.h b/src/Movement/Move.h index bf891f1e..19df4f89 100644 --- a/src/Movement/Move.h +++ b/src/Movement/Move.h @@ -159,7 +159,7 @@ public: int32_t GetAccumulatedExtrusion(size_t extruder, bool& isPrinting) noexcept; // Return and reset the accumulated commanded extrusion amount -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE bool WriteResumeSettings(FileStore *f) const noexcept; // Write settings for resuming the print #endif diff --git a/src/Platform/Platform.cpp b/src/Platform/Platform.cpp index 1bb22aac..15905d28 100644 --- a/src/Platform/Platform.cpp +++ b/src/Platform/Platform.cpp @@ -2439,6 +2439,12 @@ GCodeResult Platform::DiagnosticTest(GCodeBuffer& gb, const StringRef& reply, Ou #endif break; +#if HAS_VOLTAGE_MONITOR + case (unsigned int)DiagnosticTestType::UndervoltageEvent: + reprap.GetGCodes().LowVoltagePause(); + break; +#endif + #ifdef DUET_NG case (unsigned int)DiagnosticTestType::PrintExpanderStatus: reply.printf("Expander status %04X\n", DuetExpansion::DiagnosticRead()); @@ -4100,10 +4106,6 @@ bool Platform::FileExists(const char* folder, const char *filename) const noexce return MassStorage::CombineName(location.GetRef(), folder, filename) && MassStorage::FileExists(location.c_str()); } -#endif - -#if HAS_MASS_STORAGE - // Return a pointer to a string holding the directory where the system files are. Lock the sysdir lock before calling this. const char* Platform::InternalGetSysDir() const noexcept { @@ -4116,12 +4118,6 @@ bool Platform::Delete(const char* folder, const char *filename) const noexcept return MassStorage::CombineName(location.GetRef(), folder, filename) && MassStorage::Delete(location.c_str(), true); } -bool Platform::DirectoryExists(const char *folder, const char *dir) const noexcept -{ - String<MaxFilenameLength> location; - return MassStorage::CombineName(location.GetRef(), folder, dir) && MassStorage::DirectoryExists(location.c_str()); -} - // Set the system files path GCodeResult Platform::SetSysDir(const char* dir, const StringRef& reply) noexcept { diff --git a/src/Platform/Platform.h b/src/Platform/Platform.h index ac73580e..41e48c54 100644 --- a/src/Platform/Platform.h +++ b/src/Platform/Platform.h @@ -184,6 +184,7 @@ enum class DiagnosticTestType : unsigned int PrintObjectAddresses = 106, // print the addresses and sizes of various objects TimeCRC32 = 107, // time how long it takes to calculate CRC32 TimeGetTimerTicks = 108, // time now long it takes to read the step clock + UndervoltageEvent = 109, // pretend an undervoltage condition has occurred #ifdef __LPC17xx__ PrintBoardConfiguration = 200, // Prints out all pin/values loaded from SDCard to configure board @@ -395,10 +396,7 @@ public: #if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE FileStore* OpenFile(const char* folder, const char* fileName, OpenMode mode, uint32_t preAllocSize = 0) const noexcept; bool FileExists(const char* folder, const char *filename) const noexcept; -#endif -#if HAS_MASS_STORAGE bool Delete(const char* folder, const char *filename) const noexcept; - bool DirectoryExists(const char *folder, const char *dir) const noexcept; const char* GetWebDir() const noexcept; // Where the html etc files are const char* GetGCodeDir() const noexcept; // Where the gcodes are @@ -820,7 +818,7 @@ private: #endif // Files -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE const char *sysDir; mutable ReadWriteLock sysDirLock; #endif diff --git a/src/Platform/RepRap.cpp b/src/Platform/RepRap.cpp index b7205959..a007c5d3 100644 --- a/src/Platform/RepRap.cpp +++ b/src/Platform/RepRap.cpp @@ -2502,21 +2502,22 @@ size_t RepRap::GetStatusIndex() const noexcept : (gCodes->GetPauseState() == PauseState::pausing) ? 4 // Pausing : (gCodes->GetPauseState() == PauseState::resuming) ? 5 // Resuming : (gCodes->GetPauseState() == PauseState::paused) ? 6 // Paused + : (gCodes->GetPauseState() == PauseState::cancelling) ? 7 // Paused : (printMonitor->IsPrinting()) - ? ((gCodes->IsSimulating()) ? 7 // Simulating - : 8 // Printing + ? ((gCodes->IsSimulating()) ? 8 // Simulating + : 9 // Printing ) - : (gCodes->IsDoingToolChange()) ? 9 // Changing tool + : (gCodes->IsDoingToolChange()) ? 10 // Changing tool : (gCodes->DoingFileMacro() || !move->NoLiveMovement() || - gCodes->WaitingForAcknowledgement()) ? 10 // Busy - : 11; // Idle + gCodes->WaitingForAcknowledgement()) ? 11 // Busy + : 12; // Idle } // Get the status character for the new-style status response char RepRap::GetStatusCharacter() const noexcept { - return "CFHODRSMPTBI"[GetStatusIndex()]; + return "CFHODRSAMPTBI"[GetStatusIndex()]; } const char* RepRap::GetStatusString() const noexcept @@ -2530,6 +2531,7 @@ const char* RepRap::GetStatusString() const noexcept "pausing", "resuming", "paused", + "cancelling", "simulating", "processing", "changingTool", @@ -2631,7 +2633,7 @@ GCodeResult RepRap::ClearTemperatureFault(int8_t wasDudHeater, const StringRef& return rslt; } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE // Save some resume information, returning true if successful // We assume that the tool configuration doesn't change, only the temperatures and the mix diff --git a/src/Platform/RepRap.h b/src/Platform/RepRap.h index 80cac81b..14c3a2c4 100644 --- a/src/Platform/RepRap.h +++ b/src/Platform/RepRap.h @@ -161,7 +161,7 @@ public: void SetAlert(const char *msg, const char *title, int mode, float timeout, AxesBitmap controls) noexcept; void ClearAlert() noexcept; -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE bool WriteToolSettings(FileStore *f) noexcept; // save some information for the resume file bool WriteToolParameters(FileStore *f, const bool forceWriteOffsets) noexcept; // save some information in config-override.g #endif diff --git a/src/Tools/Tool.cpp b/src/Tools/Tool.cpp index b9967295..20ff5f09 100644 --- a/src/Tools/Tool.cpp +++ b/src/Tools/Tool.cpp @@ -572,7 +572,7 @@ void Tool::DefineMix(const float m[]) noexcept reprap.ToolsUpdated(); } -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE // Write the tool's settings to file returning true if successful. The settings written leave the tool selected unless it is off. bool Tool::WriteSettings(FileStore *f) const noexcept diff --git a/src/Tools/Tool.h b/src/Tools/Tool.h index a12356ef..01c26ffc 100644 --- a/src/Tools/Tool.h +++ b/src/Tools/Tool.h @@ -98,7 +98,7 @@ public: uint32_t GetSpindleRpm() const noexcept { return spindleRpm; } void SetSpindleRpm(uint32_t rpm) THROWS(GCodeException); -#if HAS_MASS_STORAGE +#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE bool WriteSettings(FileStore *f) const noexcept; // write the tool's settings to file #endif |