From d991f5747e8d8c159c944cd34a25bfa23ef70ffe Mon Sep 17 00:00:00 2001 From: packerlschupfer <83344883+packerlschupfer@users.noreply.github.com> Date: Sun, 31 May 2026 11:43:05 +0200 Subject: [PATCH] =?UTF-8?q?fix(USBSerial):=20bump=20per-line=20capture=20b?= =?UTF-8?q?uffer=20128=20=E2=86=92=20512=20bytes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The USBSerial class buffers each line written to USB CDC and (when set) hands it to a lineBufferHook callback once the newline arrives. The buffer was 128 bytes; any line longer than 125 chars got truncated by LineBufferAppend() with ".." appended in place of the rest, with no way for the hook consumer to recover the rest of the line. 128 B is below several common Marlin response lines: - M115 FIRMWARE_NAME line: ~240 chars on most printers (FIRMWARE_NAME + version + URL + PROTOCOL_VERSION + MACHINE_TYPE + EXTRUDER_COUNT + UUID, all concatenated). - M503 settings dumps: many lines, several over 100. - M118 user-emitted messages: no documented length cap. The truncated output is misleading because the user can see *part* of the answer they wanted (e.g. the FIRMWARE_NAME prefix in M115) but the trailing bytes — including the UUID, which support cases sometimes need — disappear. Bump to 512 B. The ".." truncation marker still triggers for the rare line that's longer, so the behaviour degrades gracefully; only the threshold moves up. Static cost is one extra 384-byte buffer (single global USBSerial instance) — negligible vs the 196 KB total RAM on the xBuddy STM32F427. The truncation logic itself was already parametrised on lineBuffer.size() in USBSerial.cpp, so no code change there. --- lib/Arduino_Core_Buddy/cores/arduino/USBSerial.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Arduino_Core_Buddy/cores/arduino/USBSerial.h b/lib/Arduino_Core_Buddy/cores/arduino/USBSerial.h index 4905956969..eea1629766 100644 --- a/lib/Arduino_Core_Buddy/cores/arduino/USBSerial.h +++ b/lib/Arduino_Core_Buddy/cores/arduino/USBSerial.h @@ -8,7 +8,16 @@ class USBSerial : public Stream { private: bool enabled; bool isWriteOnly; - std::array lineBuffer; + // Per-line capture buffer fed by every char written to USB. Used by + // the lineBufferHook callback (e.g. WUI's /api/v1/log serial capture). + // 128 B was too small for several common Marlin lines: M115's + // FIRMWARE_NAME response is ~240 chars, full M503 settings dumps can + // exceed 200, and M118 user messages have no documented cap. Anything + // over the buffer was truncated to "..\n" in the hook output with no + // way for downstream tooling to recover the rest of the line. + // 512 B comfortably fits M115/M503/typical M118 with margin; the + // ".." truncation marker still triggers if a line happens to exceed. + std::array lineBuffer; decltype(lineBuffer)::size_type lineBufferUsed; static constexpr int32_t writeTimeoutUs = 3'000'000;