From 4f3f00bb22fdf400899817c5e79e63345aca56ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=AB=8B=E5=B8=AE?= <3294713004@qq.com> Date: Sun, 23 Mar 2025 02:02:39 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=E4=BF=AE=E5=A4=8Delectron=E4=B8=8Bardui?= =?UTF-8?q?no=E5=9C=A8=E4=B8=8A=E4=BC=A0=E5=90=8E=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=8C=BA=E4=B8=B2=E5=8F=A3=E6=B3=A2=E7=89=B9?= =?UTF-8?q?=E7=8E=87=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/modules/mixly-modules/common/serial.js | 3 +++ common/modules/mixly-modules/electron/arduino-shell.js | 2 +- common/modules/mixly-modules/electron/serial.js | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/common/modules/mixly-modules/common/serial.js b/common/modules/mixly-modules/common/serial.js index b394f69f..06c00045 100644 --- a/common/modules/mixly-modules/common/serial.js +++ b/common/modules/mixly-modules/common/serial.js @@ -335,6 +335,9 @@ class Serial { if (this.isOpened()) { await this.close(); } + this.#events_ = null; + this.#encoder_ = null; + this.#decoder_ = null; } bind(type, func) { diff --git a/common/modules/mixly-modules/electron/arduino-shell.js b/common/modules/mixly-modules/electron/arduino-shell.js index b151c152..1d8f9e08 100644 --- a/common/modules/mixly-modules/electron/arduino-shell.js +++ b/common/modules/mixly-modules/electron/arduino-shell.js @@ -341,7 +341,7 @@ ArduShell.upload = (boardType, port) => { statusBarSerial.open() .then(() => { const baudRates = code.match(/(?<=Serial.begin[\s]*\([\s]*)[0-9]*(?=[\s]*\))/g); - if (!baudRates.length) { + if (!baudRates?.length) { statusBarSerial.setBaudRate(9600); } else { statusBarSerial.setBaudRate(baudRates[0] - 0); diff --git a/common/modules/mixly-modules/electron/serial.js b/common/modules/mixly-modules/electron/serial.js index e2ad87fb..43b38571 100644 --- a/common/modules/mixly-modules/electron/serial.js +++ b/common/modules/mixly-modules/electron/serial.js @@ -258,6 +258,13 @@ class ElectronSerial extends Serial { super.onChar(char); } } + + async dispose() { + await super.dispose(); + this.#parserBytes_ = null; + this.#parserLine_ = null; + this.#serialport_ = null; + } } Electron.Serial = ElectronSerial;