diff --git a/main.html b/main.html index 4c89303..af120f4 100644 --- a/main.html +++ b/main.html @@ -82,7 +82,7 @@ let device, server, cmdChar; let maxCharSize = 20; let lastStatusFlags = 0; - + let stdoutBuffer = ''; function log(msg) { const el = document.getElementById('log'); el.textContent += msg + '\n'; @@ -161,8 +161,16 @@ const type = data[0]; if (type === EVT_WRITE_STDOUT) { - const text = new TextDecoder().decode(data.slice(1)); - log('[stdout] ' + text); + // Buffer and reassemble split packets + stdoutBuffer += new TextDecoder().decode(data.slice(1)); + const lines = stdoutBuffer.split('\n'); + stdoutBuffer = lines.pop() || ''; // Keep incomplete line + + for (const line of lines) { + if (line.trim()) { + log('[stdout] ' + line); + } + } } else if (type === EVT_STATUS_REPORT) { const view = new DataView(data.buffer); const flags = view.getUint32(1, true);