Skip to content

Commit

Permalink
Merge pull request #367 from Windfisch/fix_port_flickering
Browse files Browse the repository at this point in the history
Fix port flickering
  • Loading branch information
petervanderwalt committed Sep 30, 2024
2 parents 7a7d712 + 69660c5 commit f108631
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ function checkPowerSettings() {
}


var oldportslist, oldiplist;
var oldiplist;
var oldpinslist;
const iconPath = path.join(__dirname, 'app/icon.png');
const iconNoComm = path.join(__dirname, 'app/icon-notconnected.png');
Expand Down Expand Up @@ -525,33 +525,14 @@ async function findPorts() {
}
findPorts()

async function findChangedPorts() {
const ports = await SerialPort.list()
// console.log(ports)
status.comms.interfaces.ports = ports;
if (!_.isEqual(ports, oldportslist)) {
var newPorts = _.differenceWith(ports, oldportslist, _.isEqual)
if (newPorts.length > 0) {
debug_log("Plugged " + newPorts[0].path);
}
var removedPorts = _.differenceWith(oldportslist, ports, _.isEqual)
if (removedPorts.length > 0) {
debug_log("Unplugged " + removedPorts[0].path);
}
}
oldportslist = ports;
// throw new Error('No ports found')
findPorts()
}

// async function findDisks() {
// const drives = await drivelist.list();
// status.interface.diskdrives = drives;
// } // removed in 1.0.350 due to Drivelist stability issues

var PortCheckinterval = setInterval(function() {
if (status.comms.connectionStatus == 0) {
findChangedPorts();
findPorts();
}
//findDisks(); // removed in 1.0.350 due to Drivelist stability issues
}, 1000);
Expand Down

0 comments on commit f108631

Please sign in to comment.