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;