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);