Added logging to the arduino module to list all connected devices.

This commit is contained in:
sixteenmillimeter 2020-08-18 14:20:43 -04:00
parent d501623290
commit 7c61af7043
5 changed files with 29 additions and 6 deletions

View File

@ -35,6 +35,11 @@ class Arduino {
this.timer = 0;
this.lock = false;
this.locks = {};
this.init();
}
async init() {
const Log = require('log');
this.log = await Log({ label: 'arduino' });
}
/**
* Enumerate all connected devices that might be Arduinos
@ -50,7 +55,8 @@ class Arduino {
catch (err) {
throw err;
}
//console.dir(ports)
this.log.info('Available ports:');
this.log.info(ports.map((port) => { return port.path; }).join(','));
ports.forEach((port) => {
if (this.known.indexOf(port.path) !== -1) {
matches.push(port.path);
@ -100,6 +106,7 @@ class Arduino {
async send(serial, cmd) {
const device = this.alias[serial];
let results;
console.log(`${cmd} -> ${serial}`);
if (this.locks[serial]) {
return false;
}

File diff suppressed because one or more lines are too long

View File

@ -35,6 +35,11 @@ class Arduino {
this.timer = 0;
this.lock = false;
this.locks = {};
this.init();
}
async init() {
const Log = require('log');
this.log = await Log({ label: 'arduino' });
}
/**
* Enumerate all connected devices that might be Arduinos
@ -50,7 +55,8 @@ class Arduino {
catch (err) {
throw err;
}
//console.dir(ports)
this.log.info('Available ports:');
this.log.info(ports.map((port) => { return port.path; }).join(','));
ports.forEach((port) => {
if (this.known.indexOf(port.path) !== -1) {
matches.push(port.path);
@ -100,6 +106,7 @@ class Arduino {
async send(serial, cmd) {
const device = this.alias[serial];
let results;
console.log(`${cmd} -> ${serial}`);
if (this.locks[serial]) {
return false;
}

File diff suppressed because one or more lines are too long

View File

@ -32,6 +32,7 @@ const KNOWN : string[] = [
class Arduino {
private log : any;
private path : any = {}
private known : string[] = KNOWN
private alias : any = {}
@ -44,8 +45,14 @@ class Arduino {
private confirmExec : any
constructor () {
this.init()
}
async init () {
const Log = require('log');
this.log = await Log({ label : 'arduino' });
}
/**
* Enumerate all connected devices that might be Arduinos
*
@ -59,7 +66,8 @@ class Arduino {
} catch (err) {
throw err
}
//console.dir(ports)
this.log.info('Available ports:')
this.log.info(ports.map((port : any) => { return port.path }).join(','))
ports.forEach((port : any) => {
if (this.known.indexOf(port.path) !== -1) {
matches.push(port.path)
@ -106,6 +114,7 @@ class Arduino {
async send (serial : string, cmd : string) {
const device : any = this.alias[serial]
let results : any
console.log(`${cmd} -> ${serial}`)
if (this.locks[serial]) {
return false
}