From 2a306af9f12da5440c725933fb1224efedf01849 Mon Sep 17 00:00:00 2001 From: Christian Hammacher Date: Thu, 2 Jan 2020 18:27:57 +0100 Subject: One more DSF-related hotfix --- src/GCodes/GCodeBuffer/GCodeBuffer.cpp | 9 ++++--- src/Linux/LinuxInterface.cpp | 45 ++++++++++++++++------------------ 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/GCodes/GCodeBuffer/GCodeBuffer.cpp b/src/GCodes/GCodeBuffer/GCodeBuffer.cpp index ee94d056..d9913b68 100644 --- a/src/GCodes/GCodeBuffer/GCodeBuffer.cpp +++ b/src/GCodes/GCodeBuffer/GCodeBuffer.cpp @@ -24,18 +24,19 @@ GCodeBuffer::GCodeBuffer(GCodeChannel channel, GCodeInput *normalIn, FileGCodeIn #endif responseMessageType(mt), toolNumberAdjust(0), isBinaryBuffer(false), binaryParser(*this), stringParser(*this), machineState(new GCodeMachineState()) -#if HAS_LINUX_INTERFACE - , reportMissingMacro(false), isMacroFromCode(false), abortFile(false), abortAllFiles(false), reportStack(false) -#endif { machineState->compatibility = c; - Init(); + Reset(); } // Reset it to its state after start-up void GCodeBuffer::Reset() { while (PopState(false)) { } +#if HAS_LINUX_INTERFACE + requestedMacroFile.Clear(); + reportMissingMacro = isMacroFromCode = abortFile = abortAllFiles = reportStack = false; +#endif isBinaryBuffer = false; Init(); } diff --git a/src/Linux/LinuxInterface.cpp b/src/Linux/LinuxInterface.cpp index 3535b60c..25c6e8c7 100644 --- a/src/Linux/LinuxInterface.cpp +++ b/src/Linux/LinuxInterface.cpp @@ -419,37 +419,34 @@ void LinuxInterface::Spin() } wasConnected = true; } - else if (!transfer->IsConnected()) + else if (!transfer->IsConnected() && wasConnected) { - if (wasConnected) - { - reprap.GetPlatform().Message(NetworkInfoMessage, "Lost connection to Linux\n"); + reprap.GetPlatform().Message(NetworkInfoMessage, "Lost connection to Linux\n"); - wasConnected = false; - numDisconnects++; + wasConnected = false; + numDisconnects++; - rxPointer = txPointer = txLength = 0; - sendBufferUpdate = true; - iapWritePointer = IAP_IMAGE_START; + rxPointer = txPointer = txLength = 0; + sendBufferUpdate = true; + iapWritePointer = IAP_IMAGE_START; - if (!requestedFileName.IsEmpty()) - { - requestedFileDataLength = -1; - requestedFileSemaphore.Give(); - } + if (!requestedFileName.IsEmpty()) + { + requestedFileDataLength = -1; + requestedFileSemaphore.Give(); + } - // Don't cache any messages if they cannot be sent - gcodeReply->ReleaseAll(); + // Don't cache any messages if they cannot be sent + gcodeReply->ReleaseAll(); - // Close all open G-code files - for (size_t i = 0; i < NumGCodeChannels; i++) - { - GCodeBuffer *gb = reprap.GetGCodes().GetGCodeBuffer((GCodeChannel)i); - gb->AbortFile(true, false); - gb->MessageAcknowledged(true); - } - reprap.GetGCodes().StopPrint(StopPrintReason::abort); + // Close all open G-code files + for (size_t i = 0; i < NumGCodeChannels; i++) + { + GCodeBuffer *gb = reprap.GetGCodes().GetGCodeBuffer((GCodeChannel)i); + gb->AbortFile(true, false); + gb->MessageAcknowledged(true); } + reprap.GetGCodes().StopPrint(StopPrintReason::abort); // Invalidate the G-code buffers holding binary data (if applicable) for (size_t i = 0; i < NumGCodeChannels; i++) -- cgit v1.2.3