Skip to content

Commit 3904a3f

Browse files
fix(USBSerial): bump per-line capture buffer 128 → 512 bytes
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.
1 parent b91eeda commit 3904a3f

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

lib/Arduino_Core_Buddy/cores/arduino/USBSerial.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@ class USBSerial : public Stream {
88
private:
99
bool enabled;
1010
bool isWriteOnly;
11-
std::array<uint8_t, 128> lineBuffer;
11+
// Per-line capture buffer fed by every char written to USB. Used by
12+
// the lineBufferHook callback (e.g. WUI's /api/v1/log serial capture).
13+
// 128 B was too small for several common Marlin lines: M115's
14+
// FIRMWARE_NAME response is ~240 chars, full M503 settings dumps can
15+
// exceed 200, and M118 user messages have no documented cap. Anything
16+
// over the buffer was truncated to "..\n" in the hook output with no
17+
// way for downstream tooling to recover the rest of the line.
18+
// 512 B comfortably fits M115/M503/typical M118 with margin; the
19+
// ".." truncation marker still triggers if a line happens to exceed.
20+
std::array<uint8_t, 512> lineBuffer;
1221
decltype(lineBuffer)::size_type lineBufferUsed;
1322
static constexpr int32_t writeTimeoutUs = 3'000'000;
1423

0 commit comments

Comments
 (0)