From 49834aa514cdcb180b246ac55cbb12c58f125d29 Mon Sep 17 00:00:00 2001 From: David Crocker Date: Thu, 14 Dec 2023 10:22:48 +0000 Subject: [PATCH] Fix for lost data in BufferedGCodeInput --- src/GCodes/GCodeInput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GCodes/GCodeInput.cpp b/src/GCodes/GCodeInput.cpp index 26a5f7a2ad..8416912d56 100644 --- a/src/GCodes/GCodeInput.cpp +++ b/src/GCodes/GCodeInput.cpp @@ -126,7 +126,7 @@ bool BufferedStreamGCodeInput::FillBuffer(GCodeBuffer *gb) noexcept const size_t spaceLeft = BufferSpaceLeft(); if (spaceLeft >= GCodeInputUSBReadThreshold) { - const size_t maxToTransfer = (readingPointer > writingPointer) ? spaceLeft : GCodeInputBufferSize - writingPointer; + const size_t maxToTransfer = (readingPointer > writingPointer || writingPointer == 0) ? spaceLeft : GCodeInputBufferSize - writingPointer; writingPointer = (writingPointer + device.readBytes(buffer + writingPointer, maxToTransfer)) % GCodeInputBufferSize; } return StandardGCodeInput::FillBuffer(gb);