Update: 更新Mixly.Electron.Serial

This commit is contained in:
王立帮
2024-08-24 17:38:33 +08:00
parent 8c598e50b7
commit 8a02317143
2 changed files with 5 additions and 2 deletions

View File

@@ -1464,6 +1464,7 @@
"Mixly.Env",
"Mixly.Msg",
"Mixly.Debug",
"Mixly.MArray",
"Mixly.Electron"
],
"provide": [

View File

@@ -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]) {