From 8a02317143bdba77282906eee0ead5c568793448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=AB=8B=E5=B8=AE?= <3294713004@qq.com> Date: Sat, 24 Aug 2024 17:38:33 +0800 Subject: [PATCH] =?UTF-8?q?Update:=20=E6=9B=B4=E6=96=B0Mixly.Electron.Seri?= =?UTF-8?q?al?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/modules/mixly-modules/deps.json | 1 + common/modules/mixly-modules/electron/serial.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/common/modules/mixly-modules/deps.json b/common/modules/mixly-modules/deps.json index 37fb7e4e..7c58c146 100644 --- a/common/modules/mixly-modules/deps.json +++ b/common/modules/mixly-modules/deps.json @@ -1464,6 +1464,7 @@ "Mixly.Env", "Mixly.Msg", "Mixly.Debug", + "Mixly.MArray", "Mixly.Electron" ], "provide": [ diff --git a/common/modules/mixly-modules/electron/serial.js b/common/modules/mixly-modules/electron/serial.js index 5f48c3df..aaafac3e 100644 --- a/common/modules/mixly-modules/electron/serial.js +++ b/common/modules/mixly-modules/electron/serial.js @@ -5,6 +5,7 @@ goog.require('Mixly.Serial'); goog.require('Mixly.Env'); goog.require('Mixly.Msg'); goog.require('Mixly.Debug'); +goog.require('Mixly.MArray'); goog.require('Mixly.Electron'); goog.provide('Mixly.Electron.Serial'); @@ -22,6 +23,7 @@ const { Env, Msg, Debug, + MArray, Electron } = Mixly; @@ -45,8 +47,8 @@ class ElectronSerial extends Serial { this.getPorts = async function () { return new Promise((resolve, reject) => { if (Env.currentPlatform === 'linux') { - child_process.exec('ls /dev/ttyACM* /dev/ttyUSB* /dev/tty*USB*', (err, stdout, stderr) => { - let portsName = stdout.split('\n'); + child_process.exec('ls /dev/ttyACM* /dev/tty*USB*', (err, stdout, stderr) => { + let portsName = MArray.unique(stdout.split('\n')); let newPorts = []; for (let i = 0; i < portsName.length; i++) { if (!portsName[i]) {