Skip to content

Commit

Permalink
Serial: Allow re-check of ports on page refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
stephendade committed Jul 30, 2019
1 parent 7e476d8 commit 96c7696
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ app.use(compression());
app.use(bodyParser.json());

app.get('/api/portstatus', (req, res) => {
sManager.refreshPorts();
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify({ portStatus: sManager.ports, ifaces: sManager.iface}));
});
Expand Down
10 changes: 8 additions & 2 deletions server/serialManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class serialManager {

//check the loaded settings against the current config
// ie valid ports and IP's
this.ports = this.SyncScanSerial(this.ports, this.iface);
console.log("There are " + this.ports.length + " valid ports");
this.refreshPorts();

for (var i = 0; i < this.ports.length; i++) {
if (this.ports[i].status == 'Started') {
console.log("Starting saved link " + this.ports[i].name);
Expand All @@ -51,6 +51,12 @@ class serialManager {

}

refreshPorts() {
//Scan for all serial ports
this.ports = this.SyncScanSerial(this.ports, this.iface);
console.log("There are " + this.ports.length + " valid ports");
}

updateLinkSettings(newPortInfo) {
//update the settings for 1 port
//start/stop as required
Expand Down

0 comments on commit 96c7696

Please sign in to comment.