diff options
author | Christian Hammacher <bmasterc@gmail.com> | 2021-10-28 14:58:15 +0300 |
---|---|---|
committer | Christian Hammacher <bmasterc@gmail.com> | 2021-10-28 14:58:15 +0300 |
commit | 8207b22cc13e7893ae1cb43f4aef4a7632cac5b3 (patch) | |
tree | bd49861385980e72aeb6fe16fae0c3acc5895852 /src/GCodes | |
parent | 5e9d621403eb54b00a84d4824b75c056121730aa (diff) |
SBC improvements for 3.4-b6
Refactored various parts of the SBC interface
Renamed Linux to SBC in various places
CAN updater checks if file is present on SBC before update
SBC task is only woken up when SPI transfers finish
Bug fix: Codes that were sent back to the SBC (e.g. from USB) caused temp reports to be printed
Bug fix: SBC reconnects could take longer than expected
Diffstat (limited to 'src/GCodes')
-rw-r--r-- | src/GCodes/GCodeBuffer/BinaryParser.cpp | 2 | ||||
-rw-r--r-- | src/GCodes/GCodeBuffer/BinaryParser.h | 4 | ||||
-rw-r--r-- | src/GCodes/GCodeBuffer/GCodeBuffer.cpp | 64 | ||||
-rw-r--r-- | src/GCodes/GCodeBuffer/GCodeBuffer.h | 28 | ||||
-rw-r--r-- | src/GCodes/GCodeBuffer/StringParser.cpp | 10 | ||||
-rw-r--r-- | src/GCodes/GCodeMachineState.cpp | 18 | ||||
-rw-r--r-- | src/GCodes/GCodeMachineState.h | 10 | ||||
-rw-r--r-- | src/GCodes/GCodeQueue.cpp | 8 | ||||
-rw-r--r-- | src/GCodes/GCodeQueue.h | 2 | ||||
-rw-r--r-- | src/GCodes/GCodes.cpp | 138 | ||||
-rw-r--r-- | src/GCodes/GCodes.h | 18 | ||||
-rw-r--r-- | src/GCodes/GCodes2.cpp | 65 | ||||
-rw-r--r-- | src/GCodes/GCodes3.cpp | 12 | ||||
-rw-r--r-- | src/GCodes/GCodes4.cpp | 24 | ||||
-rw-r--r-- | src/GCodes/ObjectTracker.cpp | 2 | ||||
-rw-r--r-- | src/GCodes/ObjectTracker.h | 2 |
16 files changed, 205 insertions, 202 deletions
diff --git a/src/GCodes/GCodeBuffer/BinaryParser.cpp b/src/GCodes/GCodeBuffer/BinaryParser.cpp index 8d98102d..954c4e29 100644 --- a/src/GCodes/GCodeBuffer/BinaryParser.cpp +++ b/src/GCodes/GCodeBuffer/BinaryParser.cpp @@ -7,7 +7,7 @@ #include "BinaryParser.h" -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE #include "GCodeBuffer.h" #include "ExpressionParser.h" diff --git a/src/GCodes/GCodeBuffer/BinaryParser.h b/src/GCodes/GCodeBuffer/BinaryParser.h index adb2286b..3c1dcbda 100644 --- a/src/GCodes/GCodeBuffer/BinaryParser.h +++ b/src/GCodes/GCodeBuffer/BinaryParser.h @@ -10,9 +10,9 @@ #include <RepRapFirmware.h> -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE -#include <Linux/LinuxMessageFormats.h> +#include <SBC/SbcMessageFormats.h> #include <GCodes/GCodeException.h> #include <GCodes/GCodeMachineState.h> diff --git a/src/GCodes/GCodeBuffer/GCodeBuffer.cpp b/src/GCodes/GCodeBuffer/GCodeBuffer.cpp index 404dc653..5f212eac 100644 --- a/src/GCodes/GCodeBuffer/GCodeBuffer.cpp +++ b/src/GCodes/GCodeBuffer/GCodeBuffer.cpp @@ -11,8 +11,8 @@ #if HAS_MASS_STORAGE || HAS_EMBEDDED_FILES # include <GCodes/GCodeInput.h> #endif -#if HAS_LINUX_INTERFACE -# include <Linux/LinuxInterface.h> +#if HAS_SBC_INTERFACE +# include <SBC/SbcInterface.h> #endif #include "BinaryParser.h" #include "StringParser.h" @@ -22,7 +22,7 @@ #include <Movement/StepTimer.h> // Macros to reduce the amount of explicit conditional compilation in this file -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE # define PARSER_OPERATION(_x) ((isBinaryBuffer) ? (binaryParser._x) : (stringParser._x)) # define IS_BINARY_OR(_x) ((isBinaryBuffer) || (_x)) @@ -93,16 +93,16 @@ GCodeBuffer::GCodeBuffer(GCodeChannel::RawType channel, GCodeInput *normalIn, Fi fileInput(fileIn), #endif responseMessageType(mt), lastResult(GCodeResult::ok), -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE binaryParser(*this), #endif stringParser(*this), machineState(new GCodeMachineState()), whenReportDueTimerStarted(millis()), -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE isBinaryBuffer(false), #endif timerRunning(false), motionCommanded(false) -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE , isWaitingForMacro(false), invalidated(false) #endif { @@ -114,7 +114,7 @@ GCodeBuffer::GCodeBuffer(GCodeChannel::RawType channel, GCodeInput *normalIn, Fi // Reset it to its state after start-up void GCodeBuffer::Reset() noexcept { -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE if (isWaitingForMacro) { ResolveMacroRequest(true, false); @@ -123,7 +123,7 @@ void GCodeBuffer::Reset() noexcept while (PopState()) { } -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE isBinaryBuffer = false; requestedMacroFile.Clear(); isWaitingForMacro = macroFileClosed = false; @@ -136,7 +136,7 @@ void GCodeBuffer::Reset() noexcept // Set it up to parse another G-code void GCodeBuffer::Init() noexcept { -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE sendToSbc = false; binaryParser.Init(); #endif @@ -190,7 +190,7 @@ void GCodeBuffer::Diagnostics(MessageType mtype) noexcept { String<StringLength256> scratchString; scratchString.copy(codeChannel.ToString()); -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE scratchString.cat(IsBinary() ? "* " : " "); #else scratchString.cat(" "); @@ -235,7 +235,7 @@ void GCodeBuffer::Diagnostics(MessageType mtype) noexcept // Add a character to the end bool GCodeBuffer::Put(char c) noexcept { -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE machineState->lastCodeFromSbc = false; isBinaryBuffer = false; #endif @@ -254,7 +254,7 @@ bool GCodeBuffer::CheckMetaCommand(const StringRef& reply) return NOT_BINARY_AND(stringParser.CheckMetaCommand(reply)); } -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE // Add an entire binary G-Code, overwriting any existing content // CAUTION! This may be called with the task scheduler suspended, so don't do anything that might block or take more than a few microseconds to execute @@ -271,7 +271,7 @@ void GCodeBuffer::PutBinary(const uint32_t *data, size_t len) noexcept // Add an entire G-Code, overwriting any existing content void GCodeBuffer::PutAndDecode(const char *str, size_t len) noexcept { -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE machineState->lastCodeFromSbc = false; isBinaryBuffer = false; #endif @@ -281,7 +281,7 @@ void GCodeBuffer::PutAndDecode(const char *str, size_t len) noexcept // Add a null-terminated string, overwriting any existing content void GCodeBuffer::PutAndDecode(const char *str) noexcept { -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE machineState->lastCodeFromSbc = false; isBinaryBuffer = false; #endif @@ -290,7 +290,7 @@ void GCodeBuffer::PutAndDecode(const char *str) noexcept void GCodeBuffer::StartNewFile() noexcept { -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE machineState->SetFileExecuting(); #endif machineState->lineNumber = 0; // reset line numbering when M32 is run @@ -740,7 +740,7 @@ void GCodeBuffer::SetFinished(bool f) noexcept { if (f) { -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE sendToSbc = false; #endif LatestMachineState().firstCommandAfterRestart = false; @@ -861,8 +861,8 @@ void GCodeBuffer::AbortFile(bool abortAll, bool requestAbort) noexcept if (machineState->DoingFile()) { #if HAS_MASS_STORAGE || HAS_EMBEDDED_FILES -# if HAS_LINUX_INTERFACE - if (!reprap.UsingLinuxInterface()) +# if HAS_SBC_INTERFACE + if (!reprap.UsingSbcInterface()) # endif { fileInput->Reset(machineState->fileState); @@ -872,7 +872,7 @@ void GCodeBuffer::AbortFile(bool abortAll, bool requestAbort) noexcept } } while (PopState() && (abortAll || !machineState->DoingFile())); -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE abortFile = requestAbort; abortAllFiles = requestAbort && abortAll; } @@ -883,7 +883,7 @@ void GCodeBuffer::AbortFile(bool abortAll, bool requestAbort) noexcept } } -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE void GCodeBuffer::SetFileFinished() noexcept { @@ -912,7 +912,7 @@ void GCodeBuffer::SetFileFinished() noexcept if (macroFileId != NoFileId) { - reprap.GetLinuxInterface().EventOccurred(); + reprap.GetSbcInterface().EventOccurred(); } } @@ -929,14 +929,14 @@ void GCodeBuffer::SetPrintFinished() noexcept ms->fileFinished = true; } } - reprap.GetLinuxInterface().EventOccurred(); + reprap.GetSbcInterface().EventOccurred(); } } -// This is only called when using the Linux interface and returns if the macro file could be opened +// This is only called when using the SBC interface and returns if the macro file could be opened bool GCodeBuffer::RequestMacroFile(const char *filename, bool fromCode) noexcept { - if (!reprap.GetLinuxInterface().IsConnected()) + if (!reprap.GetSbcInterface().IsConnected()) { // Don't wait for a macro file if no SBC is connected return false; @@ -953,7 +953,7 @@ bool GCodeBuffer::RequestMacroFile(const char *filename, bool fromCode) noexcept { // Wait for a response (but not forever) isWaitingForMacro = true; - reprap.GetLinuxInterface().EventOccurred(true); + reprap.GetSbcInterface().EventOccurred(true); if (!macroSemaphore.Take(SpiMacroRequestTimeout)) { isWaitingForMacro = false; @@ -962,7 +962,7 @@ bool GCodeBuffer::RequestMacroFile(const char *filename, bool fromCode) noexcept } } - // When we get here we expect the Linux interface to have set the variables above for us + // When we get here we expect the SBC interface to have set the variables above for us if (!macroFileError) { macroJustStarted = true; @@ -984,7 +984,7 @@ void GCodeBuffer::MacroFileClosed() noexcept machineState->CloseFile(); macroJustStarted = false; macroFileClosed = true; - reprap.GetLinuxInterface().EventOccurred(); + reprap.GetSbcInterface().EventOccurred(); } #endif @@ -1000,9 +1000,9 @@ void GCodeBuffer::MessageAcknowledged(bool cancelled) noexcept ms->waitingForAcknowledgement = false; ms->messageAcknowledged = true; ms->messageCancelled = cancelled; -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE messageAcknowledged = !cancelled; - reprap.GetLinuxInterface().EventOccurred(); + reprap.GetSbcInterface().EventOccurred(); #endif } } @@ -1010,7 +1010,7 @@ void GCodeBuffer::MessageAcknowledged(bool cancelled) noexcept MessageType GCodeBuffer::GetResponseMessageType() const noexcept { -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE if (machineState->lastCodeFromSbc) { return (MessageType)((1u << codeChannel.ToBaseType()) | BinaryCodeReplyFlag); @@ -1027,8 +1027,8 @@ FilePosition GCodeBuffer::GetFilePosition() const noexcept void GCodeBuffer::WaitForAcknowledgement() noexcept { machineState->WaitForAcknowledgement(); -#if HAS_LINUX_INTERFACE - if (reprap.UsingLinuxInterface()) +#if HAS_SBC_INTERFACE + if (reprap.UsingSbcInterface()) { messagePromptPending = true; } diff --git a/src/GCodes/GCodeBuffer/GCodeBuffer.h b/src/GCodes/GCodeBuffer/GCodeBuffer.h index 878bd2e6..98a5d47e 100644 --- a/src/GCodes/GCodeBuffer/GCodeBuffer.h +++ b/src/GCodes/GCodeBuffer/GCodeBuffer.h @@ -14,7 +14,9 @@ #include <RepRapFirmware.h> #include <GCodes/GCodeChannel.h> #include <GCodes/GCodeMachineState.h> -#include <Linux/LinuxMessageFormats.h> +#if HAS_SBC_INTERFACE +# include <SBC/SbcMessageFormats.h> +#endif #include <ObjectModel/ObjectModel.h> class FileGCodeInput; @@ -48,7 +50,7 @@ public: void Diagnostics(MessageType mtype) noexcept; // Write some debug info bool Put(char c) noexcept SPEED_CRITICAL; // Add a character to the end -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE void PutBinary(const uint32_t *data, size_t len) noexcept; // Add an entire binary G-Code, overwriting any existing content #endif void PutAndDecode(const char *data, size_t len) noexcept; // Add an entire G-Code, overwriting any existing content @@ -150,7 +152,7 @@ public: void WaitForAcknowledgement() noexcept; // Flag that we are waiting for acknowledgement -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE bool IsBinary() const noexcept { return isBinaryBuffer; } // Return true if the code is in binary format bool IsFileFinished() const noexcept; // Return true if this source has finished execution of a file @@ -269,7 +271,7 @@ private: GCodeResult lastResult; -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE BinaryParser binaryParser; #endif @@ -282,20 +284,20 @@ private: uint32_t whenReportDueTimerStarted; // When the report-due-timer has been started static constexpr uint32_t reportDueInterval = 1000; // Interval in which we send in ms -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE bool isBinaryBuffer; #endif bool timerRunning; // True if we are waiting bool motionCommanded; // true if this GCode stream has commanded motion since it last waited for motion to stop -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE alignas(4) char buffer[MaxCodeBufferSize]; // must be aligned because we do dword fetches from it #else char buffer[GCODE_LENGTH]; #endif -#if HAS_LINUX_INTERFACE - // Accessed by both the Main and Linux tasks +#if HAS_SBC_INTERFACE + // Accessed by both the Main and SBC tasks BinarySemaphore macroSemaphore; volatile bool isWaitingForMacro; // Is this GB waiting in DoFileMacro? volatile bool macroFileClosed; // Last macro file has been closed in RRF, tell the SBC @@ -312,21 +314,21 @@ private: messagePromptPending : 1, // Has the SBC been notified about a message waiting for acknowledgement? messageAcknowledged : 1; // Last message has been acknowledged - // Accessed only by the Linux task + // Accessed only by the SBC task bool invalidated; // Set to true if the GB content is not valid and about to be cleared #endif }; inline bool GCodeBuffer::IsDoingFileMacro() const noexcept { -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE return machineState->doingFileMacro || IsMacroRequestPending(); #else return machineState->doingFileMacro; #endif } -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE inline bool GCodeBuffer::IsFileFinished() const noexcept { @@ -369,7 +371,7 @@ inline bool GCodeBuffer::CanQueueCodes() const noexcept inline bool GCodeBuffer::IsDoingFile() const noexcept { -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE return machineState->DoingFile() || IsMacroRequestPending(); #else return machineState->DoingFile(); @@ -389,7 +391,7 @@ inline bool GCodeBuffer::IsExecuting() const noexcept // Return true if this source is executing a file from the local SD card inline bool GCodeBuffer::IsDoingLocalFile() const noexcept { -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE return !IsBinary() && IsDoingFile(); #else return IsDoingFile(); diff --git a/src/GCodes/GCodeBuffer/StringParser.cpp b/src/GCodes/GCodeBuffer/StringParser.cpp index 9205e453..24a6aaa3 100644 --- a/src/GCodes/GCodeBuffer/StringParser.cpp +++ b/src/GCodes/GCodeBuffer/StringParser.cpp @@ -785,13 +785,13 @@ void StringParser::ProcessEchoCommand(const StringRef& reply) THROWS(GCodeExcept { SkipWhiteSpace(); -#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE FileData outputFile; #endif if (gb.buffer[readPointer] == '>') { -#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE // Redirect the line to file ++readPointer; OpenMode openMode; @@ -843,7 +843,7 @@ void StringParser::ProcessEchoCommand(const StringRef& reply) THROWS(GCodeExcept } } -#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE if (outputFile.IsLive()) { reply.cat('\n'); @@ -1062,8 +1062,8 @@ FilePosition StringParser::GetFilePosition() const noexcept { #if HAS_MASS_STORAGE if (gb.LatestMachineState().DoingFile() -# if HAS_LINUX_INTERFACE - && !reprap.UsingLinuxInterface() +# if HAS_SBC_INTERFACE + && !reprap.UsingSbcInterface() # endif ) { diff --git a/src/GCodes/GCodeMachineState.cpp b/src/GCodes/GCodeMachineState.cpp index 01d35c88..ad02bdd8 100644 --- a/src/GCodes/GCodeMachineState.cpp +++ b/src/GCodes/GCodeMachineState.cpp @@ -13,7 +13,7 @@ // Create a default initialised GCodeMachineState GCodeMachineState::GCodeMachineState() noexcept : feedRate(ConvertSpeedFromMmPerMin(DefaultFeedRate)), -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE fileId(NoFileId), #endif lineNumber(0), @@ -21,7 +21,7 @@ GCodeMachineState::GCodeMachineState() noexcept doingFileMacro(false), waitWhileCooling(false), runningM501(false), runningM502(false), volumetricExtrusion(false), g53Active(false), runningSystemMacro(false), usingInches(false), waitingForAcknowledgement(false), messageAcknowledged(false), localPush(false), macroRestartable(false), firstCommandAfterRestart(false), commandRepeated(false), -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE lastCodeFromSbc(false), macroStartedByCode(false), fileFinished(false), #endif compatibility(Compatibility::RepRapFirmware), @@ -37,7 +37,7 @@ GCodeMachineState::GCodeMachineState(GCodeMachineState& prev, bool withinSameFil #if HAS_MASS_STORAGE || HAS_EMBEDDED_FILES fileState(prev.fileState), #endif -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE fileId(prev.fileId), #endif lockedResources(prev.lockedResources), @@ -46,7 +46,7 @@ GCodeMachineState::GCodeMachineState(GCodeMachineState& prev, bool withinSameFil doingFileMacro(prev.doingFileMacro), waitWhileCooling(prev.waitWhileCooling), runningM501(prev.runningM501), runningM502(prev.runningM502), volumetricExtrusion(false), g53Active(false), runningSystemMacro(prev.runningSystemMacro), usingInches(prev.usingInches), waitingForAcknowledgement(false), messageAcknowledged(false), localPush(withinSameFile), firstCommandAfterRestart(prev.firstCommandAfterRestart), commandRepeated(false), -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE lastCodeFromSbc(prev.lastCodeFromSbc), macroStartedByCode(prev.macroStartedByCode), fileFinished(prev.fileFinished), #endif compatibility(prev.compatibility), @@ -90,7 +90,7 @@ bool GCodeMachineState::CanRestartMacro() const noexcept return true; } -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE // Set the state to indicate a file is being processed void GCodeMachineState::SetFileExecuting() noexcept @@ -114,8 +114,8 @@ void GCodeMachineState::SetFileExecuting() noexcept // Return true if we are reading GCode commands from a file or macro bool GCodeMachineState::DoingFile() const noexcept { -#if HAS_LINUX_INTERFACE - if (reprap.UsingLinuxInterface() && fileId != NoFileId) +#if HAS_SBC_INTERFACE + if (reprap.UsingSbcInterface() && fileId != NoFileId) { return true; } @@ -130,8 +130,8 @@ bool GCodeMachineState::DoingFile() const noexcept // Close the currently executing file void GCodeMachineState::CloseFile() noexcept { -#if HAS_LINUX_INTERFACE - if (reprap.UsingLinuxInterface()) +#if HAS_SBC_INTERFACE + if (reprap.UsingSbcInterface()) { if (fileId != NoFileId) { diff --git a/src/GCodes/GCodeMachineState.h b/src/GCodes/GCodeMachineState.h index f45e77f3..a6bb3e2a 100644 --- a/src/GCodes/GCodeMachineState.h +++ b/src/GCodes/GCodeMachineState.h @@ -117,7 +117,7 @@ enum class GCodeState : uint8_t timingSDread, #endif -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE waitingForAcknowledgement, #endif @@ -139,7 +139,7 @@ enum class BlockType : uint8_t loop // block inside a 'while' command }; -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE typedef uint8_t FileId; constexpr FileId NoFileId = 0; @@ -203,7 +203,7 @@ public: #if HAS_MASS_STORAGE || HAS_EMBEDDED_FILES FileData fileState; #endif -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE FileId fileId; // virtual ID to distinguish files in different stack levels (only unique per GB) #endif ResourceBitmap lockedResources; @@ -229,7 +229,7 @@ public: macroRestartable : 1, // true if the current macro has used M98 R1 to say that it can be interrupted and restarted firstCommandAfterRestart : 1, // true if this is the first command after restarting a macro that was interrupted commandRepeated : 1 // true if the current command is being repeated because it returned GCodeResult::notFinished the first time -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE , lastCodeFromSbc : 1, macroStartedByCode : 1, fileFinished : 1 @@ -244,7 +244,7 @@ public: void WaitForAcknowledgement() noexcept; -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE void SetFileExecuting() noexcept; #endif diff --git a/src/GCodes/GCodeQueue.cpp b/src/GCodes/GCodeQueue.cpp index 4fc4cb02..cf11c03b 100644 --- a/src/GCodes/GCodeQueue.cpp +++ b/src/GCodes/GCodeQueue.cpp @@ -234,10 +234,10 @@ void GCodeQueue::Diagnostics(MessageType mtype) noexcept const QueuedCode *item = queuedItems; do { -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE // The following may output binary gibberish if this code is stored in binary. // We could restore this message by using GCodeBuffer::AppendFullCommand but there is probably no need to - if (!reprap.UsingLinuxInterface()) + if (!reprap.UsingSbcInterface()) #endif { reprap.GetPlatform().MessageF(mtype, "Queued '%.*s' for move %" PRIu32 "\n", item->dataLength, item->data, item->executeAtMove); @@ -250,7 +250,7 @@ void GCodeQueue::Diagnostics(MessageType mtype) noexcept void QueuedCode::AssignFrom(GCodeBuffer &gb) noexcept { -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE isBinary = gb.IsBinary(); #endif memcpy(data, gb.DataStart(), gb.DataLength()); @@ -259,7 +259,7 @@ void QueuedCode::AssignFrom(GCodeBuffer &gb) noexcept void QueuedCode::AssignTo(GCodeBuffer *gb) noexcept { -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE if (isBinary) { // Note that the data has to remain on a 4-byte boundary for this to work diff --git a/src/GCodes/GCodeQueue.h b/src/GCodes/GCodeQueue.h index f29090e0..16a7fda9 100644 --- a/src/GCodes/GCodeQueue.h +++ b/src/GCodes/GCodeQueue.h @@ -48,7 +48,7 @@ public: private: QueuedCode *next; -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE bool isBinary; alignas(4) char data[BufferSizePerQueueItem]; #else diff --git a/src/GCodes/GCodes.cpp b/src/GCodes/GCodes.cpp index b148f5f6..440e981f 100644 --- a/src/GCodes/GCodes.cpp +++ b/src/GCodes/GCodes.cpp @@ -42,8 +42,8 @@ # include <Fans/LedStripDriver.h> #endif -#if HAS_LINUX_INTERFACE -# include <Linux/LinuxInterface.h> +#if HAS_SBC_INTERFACE +# include <SBC/SbcInterface.h> #endif #if SUPPORT_REMOTE_COMMANDS @@ -81,19 +81,18 @@ GCodes::GCodes(Platform& p) noexcept : #endif fileGCode = new GCodeBuffer(GCodeChannel::File, nullptr, fileInput, GenericMessage); -# if SUPPORT_HTTP || HAS_LINUX_INTERFACE +# if SUPPORT_HTTP || HAS_SBC_INTERFACE httpInput = new NetworkGCodeInput(); httpGCode = new GCodeBuffer(GCodeChannel::HTTP, httpInput, fileInput, HttpMessage); # else httpGCode = nullptr; -# endif // SUPPORT_HTTP || HAS_LINUX_INTERFACE -# if SUPPORT_TELNET || HAS_LINUX_INTERFACE +# endif // SUPPORT_HTTP || HAS_SBC_INTERFACE +# if SUPPORT_TELNET || HAS_SBC_INTERFACE telnetInput = new NetworkGCodeInput(); telnetGCode = new GCodeBuffer(GCodeChannel::Telnet, telnetInput, fileInput, TelnetMessage, Compatibility::Marlin); # else telnetGCode = nullptr; -# endif // SUPPORT_TELNET || HAS_LINUX_INTERFACE - +# endif // SUPPORT_TELNET || HAS_SBC_INTERFACE #if defined(SERIAL_MAIN_DEVICE) # if SAME5x // SAME5x USB driver already uses an efficient buffer for receiving data from USB @@ -103,7 +102,7 @@ GCodes::GCodes(Platform& p) noexcept : BufferedStreamGCodeInput * const usbInput = new BufferedStreamGCodeInput(SERIAL_MAIN_DEVICE); # endif usbGCode = new GCodeBuffer(GCodeChannel::USB, usbInput, fileInput, UsbMessage, Compatibility::Marlin); -#elif HAS_LINUX_INTERFACE +#elif HAS_SBC_INTERFACE usbGCode = new GCodeBuffer(GCodeChannel::USB, nullptr, fileInput, UsbMessage, Compatbility::marlin); #else usbGCode = nullptr; @@ -112,7 +111,7 @@ GCodes::GCodes(Platform& p) noexcept : #if HAS_AUX_DEVICES StreamGCodeInput * const auxInput = new StreamGCodeInput(SERIAL_AUX_DEVICE); auxGCode = new GCodeBuffer(GCodeChannel::Aux, auxInput, fileInput, AuxMessage); -#elif HAS_LINUX_INTERFACE +#elif HAS_SBC_INTERFACE auxGCode = new GCodeBuffer(GCodeChannel::Aux, nullptr, fileInput, AuxMessage); #else auxGCode = nullptr; @@ -123,13 +122,13 @@ GCodes::GCodes(Platform& p) noexcept : codeQueue = new GCodeQueue(); queuedGCode = new GCodeBuffer(GCodeChannel::Queue, codeQueue, fileInput, GenericMessage); -#if SUPPORT_12864_LCD || HAS_LINUX_INTERFACE +#if SUPPORT_12864_LCD || HAS_SBC_INTERFACE lcdGCode = new GCodeBuffer(GCodeChannel::LCD, nullptr, fileInput, LcdMessage); #else lcdGCode = nullptr; #endif -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE spiGCode = new GCodeBuffer(GCodeChannel::SBC, nullptr, fileInput, GenericMessage); #else spiGCode = nullptr; @@ -138,7 +137,7 @@ GCodes::GCodes(Platform& p) noexcept : #if defined(SERIAL_AUX2_DEVICE) StreamGCodeInput * const aux2Input = new StreamGCodeInput(SERIAL_AUX2_DEVICE); aux2GCode = new GCodeBuffer(GCodeChannel::Aux2, aux2Input, fileInput, Aux2Message); -#elif HAS_LINUX_INTERFACE +#elif HAS_SBC_INTERFACE aux2GCode = new GCodeBuffer(GCodeChannel::Aux2, nullptr, fileInput, Aux2Message); #else aux2GCode = nullptr; @@ -292,7 +291,7 @@ void GCodes::Reset() noexcept #endif doingToolChange = false; doingManualBedProbe = false; -#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE || HAS_EMBEDDED_FILES +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE || HAS_EMBEDDED_FILES fileOffsetToPrint = 0; restartMoveFractionDone = 0.0; #endif @@ -346,8 +345,8 @@ bool GCodes::WaitingForAcknowledgement() const noexcept // May return noFilePosition if allowNoFilePos is true FilePosition GCodes::GetFilePosition(bool allowNoFilePos) const noexcept { -#if HAS_LINUX_INTERFACE - if (!reprap.UsingLinuxInterface()) +#if HAS_SBC_INTERFACE + if (!reprap.UsingSbcInterface()) #endif { #if HAS_MASS_STORAGE || HAS_EMBEDDED_FILES @@ -359,7 +358,7 @@ FilePosition GCodes::GetFilePosition(bool allowNoFilePos) const noexcept #endif } -#if HAS_MASS_STORAGE || HAS_EMBEDDED_FILES || HAS_LINUX_INTERFACE +#if HAS_MASS_STORAGE || HAS_EMBEDDED_FILES || HAS_SBC_INTERFACE const FilePosition pos = (fileGCode->IsDoingFileMacro()) ? printFilePositionAtMacroStart // the position before we started executing the macro : fileGCode->GetFilePosition(); // the actual position, allowing for bytes cached but not yet processed @@ -441,7 +440,7 @@ void GCodes::Spin() noexcept // Get the GCodeBuffer that we want to process a command from. Use round-robin scheduling but give priority to auto-pause. GCodeBuffer *gbp = autoPauseGCode; if (!autoPauseGCode->IsCompletelyIdle() -#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE || HAS_EMBEDDED_FILES +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE || HAS_EMBEDDED_FILES || autoPauseGCode->LatestMachineState().DoingFile() #endif ) // if autoPause is active @@ -474,9 +473,9 @@ void GCodes::Spin() noexcept } -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE // Need to check if the print has been stopped by the SBC - if (reprap.UsingLinuxInterface() && reprap.GetLinuxInterface().IsPrintAborted()) + if (reprap.UsingSbcInterface() && reprap.GetSbcInterface().IsPrintAborted()) { StopPrint(StopPrintReason::abort); } @@ -535,8 +534,11 @@ bool GCodes::SpinGCodeBuffer(GCodeBuffer& gb) noexcept result = true; // assume we did something useful (not necessarily true, e.g. could be waiting for movement to stop) } - if ( gb.IsExecuting() - || (isWaiting && !cancelWait) // this is needed to get reports sent during M109 commands + if ((gb.IsExecuting() +#if HAS_SBC_INTERFACE + && !gb.IsSendRequested() +#endif + ) || (isWaiting && !cancelWait) // this is needed to get reports sent during M109 commands ) { CheckReportDue(gb, reply.GetRef()); @@ -614,10 +616,10 @@ bool GCodes::StartNextGCode(GCodeBuffer& gb, const StringRef& reply) noexcept return true; } } -#if HAS_LINUX_INTERFACE - else if (reprap.UsingLinuxInterface()) +#if HAS_SBC_INTERFACE + else if (reprap.UsingSbcInterface()) { - return reprap.GetLinuxInterface().FillBuffer(gb); + return reprap.GetSbcInterface().FillBuffer(gb); } #endif } @@ -627,8 +629,8 @@ bool GCodes::StartNextGCode(GCodeBuffer& gb, const StringRef& reply) noexcept // Try to continue with a print from file, returning true if we did anything significant bool GCodes::DoFilePrint(GCodeBuffer& gb, const StringRef& reply) noexcept { -#if HAS_LINUX_INTERFACE - if (reprap.UsingLinuxInterface()) +#if HAS_SBC_INTERFACE + if (reprap.UsingSbcInterface()) { if (gb.IsFileFinished()) { @@ -680,7 +682,7 @@ bool GCodes::DoFilePrint(GCodeBuffer& gb, const StringRef& reply) noexcept return true; } } - return reprap.GetLinuxInterface().FillBuffer(gb); + return reprap.GetSbcInterface().FillBuffer(gb); } } else @@ -948,15 +950,15 @@ void GCodes::DoPause(GCodeBuffer& gb, PauseReason reason, const char *msg, uint1 pauseRestorePoint.moveCoords[axis] = moveState.currentUserPosition[axis]; } -#if HAS_LINUX_INTERFACE - if (reprap.UsingLinuxInterface()) +#if HAS_SBC_INTERFACE + if (reprap.UsingSbcInterface()) { fileGCode->Init(); // clear the next move UnlockAll(*fileGCode); // release any locks it had } else - { #endif + { #if HAS_MASS_STORAGE // If we skipped any moves, reset the file pointer to the start of the first move we need to replay // The following could be delayed until we resume the print @@ -970,9 +972,7 @@ void GCodes::DoPause(GCodeBuffer& gb, PauseReason reason, const char *msg, uint1 } } #endif -#if HAS_LINUX_INTERFACE } -#endif codeQueue->PurgeEntries(); @@ -992,7 +992,7 @@ void GCodes::DoPause(GCodeBuffer& gb, PauseReason reason, const char *msg, uint1 pauseRestorePoint.toolNumber = reprap.GetCurrentToolNumber(); pauseRestorePoint.fanSpeed = lastDefaultFanSpeed; -#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE if (!IsSimulating()) { SaveResumeInfo(false); // create the resume file so that we can resume after power down @@ -1027,8 +1027,8 @@ void GCodes::DoPause(GCodeBuffer& gb, PauseReason reason, const char *msg, uint1 gb.SetState(newState, param); pauseState = PauseState::pausing; -#if HAS_LINUX_INTERFACE - if (reprap.UsingLinuxInterface()) +#if HAS_SBC_INTERFACE + if (reprap.UsingSbcInterface()) { // Get the print pause reason that is compatible with the API PrintPausedReason pauseReason = PrintPausedReason::user; @@ -1059,8 +1059,8 @@ void GCodes::DoPause(GCodeBuffer& gb, PauseReason reason, const char *msg, uint1 break; } - // Prepare notification for the Linux side - reprap.GetLinuxInterface().SetPauseReason(pauseRestorePoint.filePos, pauseReason); + // Prepare notification for the SBC + reprap.GetSbcInterface().SetPauseReason(pauseRestorePoint.filePos, pauseReason); } #endif @@ -1168,11 +1168,11 @@ bool GCodes::DoEmergencyPause() noexcept #endif } -#if HAS_LINUX_INTERFACE - if (reprap.UsingLinuxInterface()) +#if HAS_SBC_INTERFACE + if (reprap.UsingSbcInterface()) { PrintPausedReason reason = platform.IsPowerOk() ? PrintPausedReason::stall : PrintPausedReason::lowVoltage; - reprap.GetLinuxInterface().SetEmergencyPauseReason(pauseRestorePoint.filePos, reason); + reprap.GetSbcInterface().SetEmergencyPauseReason(pauseRestorePoint.filePos, reason); } #endif @@ -1331,7 +1331,7 @@ bool GCodes::ReHomeOnStall(DriversBitmap stalledDrivers) noexcept #endif -#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE void GCodes::SaveResumeInfo(bool wasPowerFailure) noexcept { @@ -2780,8 +2780,8 @@ bool GCodes::DoFileMacro(GCodeBuffer& gb, const char* fileName, bool reportMissi printFilePositionAtMacroStart = gb.GetFilePosition(); } -#if HAS_LINUX_INTERFACE - if (reprap.UsingLinuxInterface()) +#if HAS_SBC_INTERFACE + if (reprap.UsingSbcInterface()) { if (!gb.RequestMacroFile(fileName, gb.IsBinary() && codeRunning != AsyncSystemMacroCode)) { @@ -2842,7 +2842,7 @@ bool GCodes::DoFileMacro(GCodeBuffer& gb, const char* fileName, bool reportMissi #endif } -#if HAS_LINUX_INTERFACE || HAS_MASS_STORAGE || HAS_EMBEDDED_FILES +#if HAS_SBC_INTERFACE || HAS_MASS_STORAGE || HAS_EMBEDDED_FILES gb.LatestMachineState().doingFileMacro = true; // The following three flags need to be inherited in the case that a system macro calls another macro, e.g.homeall.g calls homez.g. The Push call copied them over already. @@ -2873,8 +2873,8 @@ bool GCodes::DoFileMacro(GCodeBuffer& gb, const char* fileName, bool reportMissi gb.SetState(GCodeState::normal); gb.Init(); -# if HAS_LINUX_INTERFACE - if (!reprap.UsingLinuxInterface() && codeRunning != AsyncSystemMacroCode) +# if HAS_SBC_INTERFACE + if (!reprap.UsingSbcInterface() && codeRunning != AsyncSystemMacroCode) # endif { // Don't notify DSF when files are requested asynchronously, it creates excessive traffic @@ -2895,8 +2895,8 @@ void GCodes::FileMacroCyclesReturn(GCodeBuffer& gb) noexcept { if (gb.IsDoingFileMacro()) { -#if HAS_LINUX_INTERFACE - if (reprap.UsingLinuxInterface()) +#if HAS_SBC_INTERFACE + if (reprap.UsingSbcInterface()) { gb.AbortFile(false); } @@ -3117,9 +3117,9 @@ GCodeResult GCodes::ProbeGrid(GCodeBuffer& gb, const StringRef& reply) GCodeResult GCodes::LoadHeightMap(GCodeBuffer& gb, const StringRef& reply) { -#if HAS_LINUX_INTERFACE - // If we have a Linux interface and we're using it, the Linux components will take care of file I/O and this should not be called. - if (reprap.UsingLinuxInterface()) +#if HAS_SBC_INTERFACE + // If we have an SBC interface and we're using it, the SBC service will take care of file I/O and this should not be called + if (reprap.UsingSbcInterface()) { reply.copy("Cannot use height map on local SD card when SBC interface is used"); return GCodeResult::error; @@ -3169,9 +3169,9 @@ GCodeResult GCodes::LoadHeightMap(GCodeBuffer& gb, const StringRef& reply) // Save the height map and append the success or error message to 'reply', returning true if an error occurred bool GCodes::TrySaveHeightMap(const char *filename, const StringRef& reply) const noexcept { -#if HAS_LINUX_INTERFACE - // If we have a Linux interface and we're using it, the Linux components will take care of file I/O. - if (reprap.UsingLinuxInterface()) +#if HAS_SBC_INTERFACE + // If we have an SBC connected, the SBC service will take care of heightmap-related file I/O + if (reprap.UsingSbcInterface()) { reply.copy("Cannot use height map on local SD card when SBC interface is used"); return true; @@ -3209,7 +3209,7 @@ GCodeResult GCodes::SaveHeightMap(GCodeBuffer& gb, const StringRef& reply) const { ReadLocker locker(reprap.GetMove().heightMapLock); - // No need to check if we're using the Linux interface here, because TrySaveHeightMap does that + // No need to check if we're using the SBC interface here, because TrySaveHeightMap does that already if (gb.Seen('P')) { String<MaxFilenameLength> heightMapFileName; @@ -3312,8 +3312,8 @@ void GCodes::StartPrinting(bool fromStart) noexcept rawExtruderTotal = 0.0; reprap.GetMove().ResetExtruderPositions(); -#if HAS_LINUX_INTERFACE - if (!reprap.UsingLinuxInterface()) +#if HAS_SBC_INTERFACE + if (!reprap.UsingSbcInterface()) #endif { #if HAS_MASS_STORAGE || HAS_EMBEDDED_FILES @@ -3755,8 +3755,8 @@ void GCodes::HandleReply(GCodeBuffer& gb, GCodeResult rslt, const char* reply) n // Note that 'reply' may be empty. If it isn't, then we need to append newline when sending it. void GCodes::HandleReplyPreserveResult(GCodeBuffer& gb, GCodeResult rslt, const char *reply) noexcept { -#if HAS_LINUX_INTERFACE - // Deal with replies to the Linux interface +#if HAS_SBC_INTERFACE + // Deal with replies to the SBC if (gb.LatestMachineState().lastCodeFromSbc) { MessageType type = gb.GetResponseMessageType(); @@ -3859,8 +3859,8 @@ void GCodes::HandleReply(GCodeBuffer& gb, OutputBuffer *reply) noexcept return; } -#if HAS_LINUX_INTERFACE - // Deal with replies to the Linux interface +#if HAS_SBC_INTERFACE + // Deal with replies to the SBC if (gb.IsBinary()) { platform.Message(gb.GetResponseMessageType(), reply); @@ -4136,8 +4136,8 @@ void GCodes::StopPrint(StopPrintReason reason) noexcept deferredPauseCommandPending = nullptr; pauseState = PauseState::notPaused; -#if HAS_LINUX_INTERFACE - if (reprap.UsingLinuxInterface()) +#if HAS_SBC_INTERFACE + if (reprap.UsingSbcInterface()) { fileGCode->LatestMachineState().CloseFile(); fileGCode->Init(); @@ -4250,7 +4250,7 @@ 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 || HAS_LINUX_INTERFACE +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE if (reason == StopPrintReason::normalCompletion && !IsSimulating()) { platform.DeleteSysFile(RESUME_AFTER_POWER_FAIL_G); @@ -4527,7 +4527,7 @@ void GCodes::SetAllAxesNotHomed() noexcept } } -#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE // Write the config-override file returning true if an error occurred GCodeResult GCodes::WriteConfigOverrideFile(GCodeBuffer& gb, const StringRef& reply) const noexcept @@ -4995,9 +4995,9 @@ void GCodes::ActivateHeightmap(bool activate) noexcept reprap.GetMove().GetCurrentUserPosition(moveState.coords, 0, reprap.GetCurrentTool()); ToolOffsetInverseTransform(moveState.coords, moveState.currentUserPosition); // update user coordinates to reflect any height map offset at the current position -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE // Set a dummy heightmap filename - if (reprap.UsingLinuxInterface()) + if (reprap.UsingSbcInterface()) { HeightMap& map = reprap.GetMove().AccessHeightMap(); map.SetFileName(DefaultHeightMapFile); @@ -5016,8 +5016,8 @@ bool GCodes::CheckNetworkCommandAllowed(GCodeBuffer& gb, const StringRef& reply, return false; // just ignore the command but report success } -#if HAS_LINUX_INTERFACE - if (reprap.UsingLinuxInterface()) +#if HAS_SBC_INTERFACE + if (reprap.UsingSbcInterface()) { // Networking is disabled when using the SBC interface, to save RAM reply.copy("Network-related commands are not supported when using an attached Single Board Computer"); diff --git a/src/GCodes/GCodes.h b/src/GCodes/GCodes.h index 8863ff89..5724bc6e 100644 --- a/src/GCodes/GCodes.h +++ b/src/GCodes/GCodes.h @@ -67,7 +67,7 @@ enum class PauseReason #endif }; -// Keep this in sync with PrintStopReason in Linux/MessageFormats.h +// Keep this in sync with PrintStopReason in SBC/SbcMessageFormats.h enum class StopPrintReason { normalCompletion, @@ -110,7 +110,7 @@ enum class SimulationMode : uint8_t highest = partial }; -class LinuxInterface; +class SbcInterface; // The GCode interpreter @@ -228,7 +228,7 @@ public: int GetNewToolNumber() const noexcept { return newToolNumber; } size_t GetCurrentZProbeNumber() const noexcept { return currentZProbeNumber; } - // These next two are public because they are used by class LinuxInterface + // These next two are public because they are used by class SbcInterface void UnlockAll(const GCodeBuffer& gb) noexcept; // Release all locks GCodeBuffer *GetGCodeBuffer(GCodeChannel channel) const noexcept { return gcodeSources[channel.ToBaseType()]; } @@ -424,7 +424,7 @@ private: #if SUPPORT_WORKPLACE_COORDINATES GCodeResult GetSetWorkplaceCoordinates(GCodeBuffer& gb, const StringRef& reply, bool compute) THROWS(GCodeException); // Set workspace coordinates -# if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE +# if HAS_MASS_STORAGE || HAS_SBC_INTERFACE bool WriteWorkplaceCoordinates(FileStore *f) const noexcept; # endif #endif @@ -483,13 +483,13 @@ private: GCodeResult UpdateFirmware(GCodeBuffer& gb, const StringRef &reply) THROWS(GCodeException); // Handle M997 GCodeResult SendI2c(GCodeBuffer& gb, const StringRef &reply) THROWS(GCodeException); // Handle M260 GCodeResult ReceiveI2c(GCodeBuffer& gb, const StringRef &reply) THROWS(GCodeException); // Handle M261 -#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE || HAS_EMBEDDED_FILES +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE || HAS_EMBEDDED_FILES GCodeResult SimulateFile(GCodeBuffer& gb, const StringRef &reply, const StringRef& file, bool updateFile) THROWS(GCodeException); // Handle M37 to simulate a whole file GCodeResult ChangeSimulationMode(GCodeBuffer& gb, const StringRef &reply, SimulationMode newSimMode) THROWS(GCodeException); // Handle M37 to change the simulation mode #endif GCodeResult WaitForPin(GCodeBuffer& gb, const StringRef &reply) THROWS(GCodeException); // Handle M577 -#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE GCodeResult WriteConfigOverrideFile(GCodeBuffer& gb, const StringRef& reply) const noexcept; // Write the config-override file bool WriteConfigOverrideHeader(FileStore *f) const noexcept; // Write the config-override header #endif @@ -507,7 +507,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 || HAS_LINUX_INTERFACE +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE void SaveResumeInfo(bool wasPowerFailure) noexcept; #endif @@ -541,7 +541,7 @@ private: Platform& platform; // The RepRap machine -#if HAS_NETWORKING || HAS_LINUX_INTERFACE +#if HAS_NETWORKING || HAS_SBC_INTERFACE NetworkGCodeInput* httpInput; // These cache incoming G-codes... NetworkGCodeInput* telnetInput; // ... #endif @@ -624,7 +624,7 @@ private: #if HAS_MASS_STORAGE || HAS_EMBEDDED_FILES FileData fileToPrint; // The next file to print #endif -#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE || HAS_EMBEDDED_FILES +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE || HAS_EMBEDDED_FILES FilePosition fileOffsetToPrint; // The offset to print from #endif diff --git a/src/GCodes/GCodes2.cpp b/src/GCodes/GCodes2.cpp index 8cfa658d..8a41bb53 100644 --- a/src/GCodes/GCodes2.cpp +++ b/src/GCodes/GCodes2.cpp @@ -12,8 +12,8 @@ #include "GCodeException.h" #include "GCodeQueue.h" #include "Heating/Heat.h" -#if HAS_LINUX_INTERFACE -# include <Linux/LinuxInterface.h> +#if HAS_SBC_INTERFACE +# include <SBC/SbcInterface.h> #endif #include <Movement/Move.h> #include <Networking/Network.h> @@ -281,10 +281,10 @@ bool GCodes::HandleGcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx case 29: // Grid-based bed probing -#if HAS_LINUX_INTERFACE - // Pass file- and system-related commands to DSF if they came from somewhere else. +#if HAS_SBC_INTERFACE + // Pass file- and system-related commands to the SBC service if they came from anywhere else. // They will be passed back to us via a binary buffer or separate SPI message if necessary. - if (reprap.UsingLinuxInterface() && reprap.GetLinuxInterface().IsConnected() && !gb.IsBinary()) + if (reprap.UsingSbcInterface() && reprap.GetSbcInterface().IsConnected() && !gb.IsBinary()) { gb.SendToSbc(); return false; @@ -471,9 +471,10 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx return true; // we don't simulate most M codes } -#if HAS_LINUX_INTERFACE - // Pass file- and system-related commands to DSF if they came from somewhere else. They will be passed back to us via a binary buffer or separate SPI message if necessary. - if ( reprap.UsingLinuxInterface() && reprap.GetLinuxInterface().IsConnected() && !gb.IsBinary() +#if HAS_SBC_INTERFACE + // Pass file- and system-related commands to the SBC service if they came from somewhere else. + // They will be passed back to us via a binary buffer or separate SPI message if necessary. + if ( reprap.UsingSbcInterface() && reprap.GetSbcInterface().IsConnected() && !gb.IsBinary() && ( code == 0 || code == 1 || code == 20 || code == 21 || code == 22 || code == 23 || code == 24 || code == 26 || code == 27 || code == 28 || code == 29 || code == 30 || code == 32 || code == 36 || code == 37 || code == 38 || code == 39 @@ -847,7 +848,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx break; #endif -#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE || HAS_EMBEDDED_FILES +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE || HAS_EMBEDDED_FILES case 23: // Set file to print case 32: // Select file and start SD print // We now allow a file that is being printed to chain to another file. This is required for the resume-after-power-fail functionality. @@ -866,8 +867,8 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx String<MaxFilenameLength> filename; gb.GetUnprecedentedString(filename.GetRef()); if ( -#if HAS_LINUX_INTERFACE - reprap.UsingLinuxInterface() +#if HAS_SBC_INTERFACE + reprap.UsingSbcInterface() # if HAS_MASS_STORAGE || # endif @@ -932,15 +933,15 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx } } } -#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE || HAS_EMBEDDED_FILES +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE || HAS_EMBEDDED_FILES else if ( # if HAS_MASS_STORAGE || HAS_EMBEDDED_FILES !fileToPrint.IsLive() # else true # endif -# if HAS_LINUX_INTERFACE - && !reprap.UsingLinuxInterface() +# if HAS_SBC_INTERFACE + && !reprap.UsingSbcInterface() # endif ) { @@ -964,8 +965,8 @@ 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()); -# if HAS_LINUX_INTERFACE - if (!reprap.UsingLinuxInterface()) +# if HAS_SBC_INTERFACE + if (!reprap.UsingSbcInterface()) # endif # if HAS_MASS_STORAGE || HAS_EMBEDDED_FILES { @@ -1057,7 +1058,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx } break; -#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE || HAS_EMBEDDED_FILES +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE || HAS_EMBEDDED_FILES 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'); @@ -1123,10 +1124,10 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx // For case 32, see case 23 -#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE || HAS_EMBEDDED_FILES +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE || HAS_EMBEDDED_FILES case 36: // Return file information -# if HAS_LINUX_INTERFACE - if (reprap.UsingLinuxInterface()) +# if HAS_SBC_INTERFACE + if (reprap.UsingSbcInterface()) { reprap.GetFileInfoResponse(nullptr, outBuf, true); } @@ -1147,8 +1148,8 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx break; case 37: // Simulation mode on/off, or simulate a whole file -# if HAS_LINUX_INTERFACE - if (reprap.UsingLinuxInterface() && !gb.IsBinary()) +# if HAS_SBC_INTERFACE + if (reprap.UsingSbcInterface() && !gb.IsBinary()) { reply.copy("M37 can be only started from the SBC interface"); result = GCodeResult::error; @@ -2558,8 +2559,8 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx // Don't lock the movement system, because if we do then only the channel that issues the M291 can move the axes if (sParam == 2 || sParam == 3) { -#if HAS_LINUX_INTERFACE - if (reprap.UsingLinuxInterface()) +#if HAS_SBC_INTERFACE + if (reprap.UsingSbcInterface()) { gb.SetState(GCodeState::waitingForAcknowledgement); } @@ -2989,13 +2990,13 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx result = buildObjects.HandleM486(gb, reply, outBuf); break; -#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE case 500: // Store parameters in config-override.g result = WriteConfigOverrideFile(gb, reply); break; #endif -#if HAS_MASS_STORAGE || HAS_EMBEDDED_FILES || HAS_LINUX_INTERFACE +#if HAS_MASS_STORAGE || HAS_EMBEDDED_FILES || HAS_SBC_INTERFACE case 501: // Load parameters from config-override.g if (!gb.LatestMachineState().runningM502 && !gb.LatestMachineState().runningM501) // when running M502 we ignore config-override.g { @@ -3111,8 +3112,8 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx break; case 550: // Set/report machine name -#if HAS_LINUX_INTERFACE - if (reprap.UsingLinuxInterface() && !gb.IsBinary()) +#if HAS_SBC_INTERFACE + if (reprap.UsingSbcInterface() && !gb.IsBinary()) { result = GCodeResult::errorNotSupported; } @@ -3573,11 +3574,11 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx } break; -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE case 576: // Set SPI communication parameters - if (reprap.UsingLinuxInterface()) + if (reprap.UsingSbcInterface()) { - result = reprap.GetLinuxInterface().HandleM576(gb, reply); + result = reprap.GetSbcInterface().HandleM576(gb, reply); } else { @@ -4444,7 +4445,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx break; #endif -#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE case 916: if (!platform.SysFileExists(RESUME_AFTER_POWER_FAIL_G)) { diff --git a/src/GCodes/GCodes3.cpp b/src/GCodes/GCodes3.cpp index b5ac630d..4bb98433 100644 --- a/src/GCodes/GCodes3.cpp +++ b/src/GCodes/GCodes3.cpp @@ -204,7 +204,7 @@ GCodeResult GCodes::GetSetWorkplaceCoordinates(GCodeBuffer& gb, const StringRef& return GCodeResult::ok; } -# if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE +# if HAS_MASS_STORAGE || HAS_SBC_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 @@ -405,7 +405,7 @@ GCodeResult GCodes::DefineGrid(GCodeBuffer& gb, const StringRef &reply) THROWS(G } -#if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE || HAS_EMBEDDED_FILES +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE || HAS_EMBEDDED_FILES // Handle M37 to simulate a whole file GCodeResult GCodes::SimulateFile(GCodeBuffer& gb, const StringRef &reply, const StringRef& file, bool updateFile) @@ -418,8 +418,8 @@ GCodeResult GCodes::SimulateFile(GCodeBuffer& gb, const StringRef &reply, const # if HAS_MASS_STORAGE || HAS_EMBEDDED_FILES if ( -# if HAS_LINUX_INTERFACE - reprap.UsingLinuxInterface() || +# if HAS_SBC_INTERFACE + reprap.UsingSbcInterface() || # endif QueueFileToPrint(file.c_str(), reply)) # endif @@ -432,8 +432,8 @@ GCodeResult GCodes::SimulateFile(GCodeBuffer& gb, const StringRef &reply, const } simulationTime = 0.0; exitSimulationWhenFileComplete = true; -# if HAS_LINUX_INTERFACE - updateFileWhenSimulationComplete = updateFile && !reprap.UsingLinuxInterface(); +# if HAS_SBC_INTERFACE + updateFileWhenSimulationComplete = updateFile && !reprap.UsingSbcInterface(); # else updateFileWhenSimulationComplete = updateFile; # endif diff --git a/src/GCodes/GCodes4.cpp b/src/GCodes/GCodes4.cpp index 8351be96..fa1cc47d 100644 --- a/src/GCodes/GCodes4.cpp +++ b/src/GCodes/GCodes4.cpp @@ -8,8 +8,8 @@ #include <Heating/Heat.h> #include <Endstops/ZProbe.h> -#if HAS_LINUX_INTERFACE -# include <Linux/LinuxInterface.h> +#if HAS_SBC_INTERFACE +# include <SBC/SbcInterface.h> #endif #if HAS_WIFI_NETWORKING || HAS_AUX_DEVICES @@ -22,9 +22,9 @@ // So any large local objects allocated here increase the amount of MAIN stack size needed. void GCodes::RunStateMachine(GCodeBuffer& gb, const StringRef& reply) noexcept { -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE // Wait for the G-code replies and abort requests to go before anything else is done in the state machine - if (reprap.UsingLinuxInterface() && (gb.IsAbortRequested() || gb.IsAbortAllRequested())) + if (reprap.UsingSbcInterface() && (gb.IsAbortRequested() || gb.IsAbortAllRequested())) { return; } @@ -499,8 +499,8 @@ void GCodes::RunStateMachine(GCodeBuffer& gb, const StringRef& reply) noexcept } platform.MessageF(LogWarn, "%s\n", reply.c_str()); pauseState = PauseState::paused; -#if HAS_LINUX_INTERFACE - reportPause = reprap.UsingLinuxInterface(); +#if HAS_SBC_INTERFACE + reportPause = reprap.UsingSbcInterface(); #endif gb.SetState(GCodeState::normal); } @@ -909,8 +909,8 @@ void GCodes::RunStateMachine(GCodeBuffer& gb, const StringRef& reply) noexcept reply.printf("%" PRIu32 " points probed, min error %.3f, max error %.3f, mean %.3f, deviation %.3f\n", numPointsProbed, (double)minError, (double)maxError, (double)deviation.GetMean(), (double)deviation.GetDeviationFromMean()); #if HAS_MASS_STORAGE -# if HAS_LINUX_INTERFACE - if (!reprap.UsingLinuxInterface()) +# if HAS_SBC_INTERFACE + if (!reprap.UsingSbcInterface()) # endif { if (TrySaveHeightMap(DefaultHeightMapFile, reply)) @@ -1440,7 +1440,7 @@ void GCodes::RunStateMachine(GCodeBuffer& gb, const StringRef& reply) noexcept } else { -# if HAS_MASS_STORAGE || HAS_LINUX_INTERFACE +# if HAS_MASS_STORAGE || HAS_SBC_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"); @@ -1521,7 +1521,7 @@ void GCodes::RunStateMachine(GCodeBuffer& gb, const StringRef& reply) noexcept break; #endif -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE case GCodeState::waitingForAcknowledgement: // finished M291 and the SBC expects a response next #endif case GCodeState::checkError: // we return to this state after running the retractprobe macro when there may be a stored error message @@ -1543,11 +1543,11 @@ void GCodes::RunStateMachine(GCodeBuffer& gb, const StringRef& reply) noexcept HandleReply(gb, stateMachineResult, reply.c_str()); CheckForDeferredPause(gb); -#if HAS_LINUX_INTERFACE +#if HAS_SBC_INTERFACE if (reportPause) { fileGCode->Invalidate(); - reprap.GetLinuxInterface().ReportPause(); + reprap.GetSbcInterface().ReportPause(); } #endif } diff --git a/src/GCodes/ObjectTracker.cpp b/src/GCodes/ObjectTracker.cpp index fd1af4c1..5db37dbc 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 || HAS_LINUX_INTERFACE +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE // Write the object details to file, returning true if successful bool ObjectTracker::WriteObjectDirectory(FileStore *f) const noexcept diff --git a/src/GCodes/ObjectTracker.h b/src/GCodes/ObjectTracker.h index a3b2b098..6f5d8670 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 || HAS_LINUX_INTERFACE +#if HAS_MASS_STORAGE || HAS_SBC_INTERFACE bool WriteObjectDirectory(FileStore *f) const noexcept; #endif |