From b6169b33a6c691cee0bd458f9a16a46c476349f8 Mon Sep 17 00:00:00 2001 From: Frank Palazzolo Date: Thu, 8 Dec 2022 14:57:46 -0500 Subject: [PATCH 1/2] Fix corruption of incoming UTF-8-encoded serial data --- arduino-ide-extension/src/node/monitor-service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arduino-ide-extension/src/node/monitor-service.ts b/arduino-ide-extension/src/node/monitor-service.ts index fca3c748a..533f536a2 100644 --- a/arduino-ide-extension/src/node/monitor-service.ts +++ b/arduino-ide-extension/src/node/monitor-service.ts @@ -80,6 +80,7 @@ export class MonitorService extends CoreClientAware implements Disposable { private readonly board: Board; private readonly port: Port; private readonly monitorID: string; + private streamingTextDecoder = new TextDecoder('utf8'); /** * The lightweight representation of the port configuration currently in use for the running monitor. @@ -319,7 +320,7 @@ export class MonitorService extends CoreClientAware implements Disposable { const message = typeof data === 'string' ? data - : new TextDecoder('utf8').decode(data); + : this.streamingTextDecoder.decode(data, {stream:true}); this.messages.push(...splitLines(message)); }, }, From f2108f4e55d6322b86f0c3d8aa00febd6faba1b2 Mon Sep 17 00:00:00 2001 From: Frank Palazzolo Date: Fri, 9 Dec 2022 18:30:57 -0500 Subject: [PATCH 2/2] Make TextDecoder() readonly because it can be Co-authored-by: z3bra <111462146+z3bra5hax@users.noreply.github.com> --- arduino-ide-extension/src/node/monitor-service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arduino-ide-extension/src/node/monitor-service.ts b/arduino-ide-extension/src/node/monitor-service.ts index 533f536a2..db5f100d7 100644 --- a/arduino-ide-extension/src/node/monitor-service.ts +++ b/arduino-ide-extension/src/node/monitor-service.ts @@ -80,7 +80,7 @@ export class MonitorService extends CoreClientAware implements Disposable { private readonly board: Board; private readonly port: Port; private readonly monitorID: string; - private streamingTextDecoder = new TextDecoder('utf8'); + private readonly streamingTextDecoder = new TextDecoder('utf8'); /** * The lightweight representation of the port configuration currently in use for the running monitor.