From 672db32917cc3f324d0418496d343719fc8e5c51 Mon Sep 17 00:00:00 2001 From: mattmcw Date: Mon, 12 Jun 2023 22:45:25 -0400 Subject: [PATCH] Put in place changes needed to receive a string from an arduino --- app/lib/arduino/index.js | 63 +++++++++++++++++------ app/lib/arduino/index.js.map | 2 +- app/lib/light/index.js | 2 +- app/lib/light/index.js.map | 2 +- src/arduino/index.ts | 96 +++++++++++++++++++++++++----------- src/globals.d.ts | 4 +- src/light/index.ts | 2 +- 7 files changed, 123 insertions(+), 48 deletions(-) diff --git a/app/lib/arduino/index.js b/app/lib/arduino/index.js index 52c0c79..793689e 100644 --- a/app/lib/arduino/index.js +++ b/app/lib/arduino/index.js @@ -97,7 +97,7 @@ class Arduino { }; return this.serial[device].write(cmd, (err, results) => { if (err) { - //console.error(err) + //this.log.error(err) return reject(err); } }); @@ -106,7 +106,7 @@ class Arduino { async send(serial, cmd) { const device = this.alias[serial]; let results; - //console.log(`${cmd} -> ${serial}`) + //this.log.info(`${cmd} -> ${serial}`) if (this.locks[serial]) { return false; } @@ -117,13 +117,13 @@ class Arduino { results = await this.sendAsync(device, cmd); } catch (e) { - return console.error(e); + return this.log.error(e); } this.locks[serial] = false; await eventEmitter.emit('arduino_send', cmd); return results; } - async string(serial, str) { + async sendString(serial, str) { const device = this.alias[serial]; let writeSuccess; await delay_1.delay(cfg.arduino.serialDelay); @@ -136,11 +136,44 @@ class Arduino { writeSuccess = await this.writeAsync(device, str); } catch (e) { - return console.error(e); + return this.log.error(e); } return writeSuccess; } } + async stateAsync(device) { + const cmd = cfg.arduino.cmd.state; + return new Promise((resolve, reject) => { + this.queue[cmd] = (ms) => { + return resolve(ms); + }; + return this.serial[device].write(cmd, (err, results) => { + if (err) { + //this.log.error(err) + return reject(err); + } + }); + }); + } + async state(serial) { + const device = this.alias[serial]; + let results; + if (this.locks[serial]) { + return -1; + } + this.timer = new Date().getTime(); + this.locks[serial] = true; + await delay_1.delay(cfg.arduino.serialDelay); + try { + results = await this.stateAsync(device); + } + catch (e) { + return this.log.error(e); + } + this.locks[serial] = false; + await eventEmitter.emit('arduino_state', cfg.arduino.cmd.state); + return results; + } /** * Send a string to an Arduino using async/await * @@ -163,25 +196,28 @@ class Arduino { const end = new Date().getTime(); const ms = end - this.timer; let complete; - //console.log(`${serial} -> ${data}`); + //this.log.info(`${serial} -> ${data}`); if (this.queue[data] !== undefined) { this.locks[serial] = false; complete = this.queue[data](ms); //execute callback eventEmitter.emit('arduino_end', data); delete this.queue[data]; } - else if (data === 'E') { + else if (data[0] === cfg.arduino.cmd.state) { + complete = this.queue[data](ms); + } + else if (data[0] === cfg.arduino.cmd.error) { //error state //stop sequence //throw error in ui } else { - //console.log('Received stray "' + data + '"'); //silent to user + //this.log.info('Received stray "' + data + '"') //silent to user } return ms; } aliasSerial(serial, device) { - //this.log.info(`Making "${serial}" an alias of ${device}`); + //this.log.info(`Making "${serial}" an alias of ${device}`) this.alias[serial] = device; } async connect(serial, device, confirm) { @@ -200,10 +236,10 @@ class Arduino { connectSuccess = await this.openArduino(device); } catch (e) { - console.error('failed to open: ' + e); + this.log.error('failed to open: ' + e); return reject(e); } - //console.log(`Opened connection with ${this.path[serial]} as ${serial}`); + //this.log.info(`Opened connection with ${this.path[serial]} as ${serial}`) if (!confirm) { this.serial[device].on('data', async (data) => { let d = data.toString('utf8'); @@ -222,7 +258,7 @@ class Arduino { }); } confirmEnd(data) { - //console.dir(data) + //this.log.info(data) if (data === cfg.arduino.cmd.connect || data === cfg.arduino.cmd.projector_identifier || data === cfg.arduino.cmd.camera_identifier @@ -352,7 +388,6 @@ class Arduino { } return closeSuccess; } - ; async fakeConnect(serial) { const device = '/dev/fake'; this.alias[serial] = device; @@ -378,7 +413,7 @@ class Arduino { }, fake: true }; - //console.log('Connected to fake arduino! Not real! Does not exist!'); + //this.log.info('Connected to fake arduino! Not real! Does not exist!') return true; } /** diff --git a/app/lib/arduino/index.js.map b/app/lib/arduino/index.js.map index fe8272e..fcbe902 100644 --- a/app/lib/arduino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IACJ,KAAK,CAAC,YAAY,CAAE,MAAe;QAClC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAa,EAAE,MAAY,EAAE,EAAE;YAClD,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,GAAS,EAAE,EAAE;gBAC9C,IAAI,GAAG,EAAE;oBACR,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;iBAClB;gBACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAA;YACrB,CAAC,CAAC,CAAA;QACH,CAAC,CAAC,CAAA;IACH,CAAC;CACD;AAED,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE;IACnD,MAAM,CAAC,OAAO,GAAG,UAAU,CAAO,EAAE,EAAQ,EAAE,UAAqB;QAClE,YAAY,GAAG,EAAE,CAAA;QACjB,GAAG,GAAG,CAAC,CAAA;QACP,OAAO,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC,CAAA;QACjC,OAAO,OAAO,CAAA;IACf,CAAC,CAAA;CACD"} \ No newline at end of file diff --git a/app/lib/light/index.js b/app/lib/light/index.js index 33b901b..fc738c3 100644 --- a/app/lib/light/index.js +++ b/app/lib/light/index.js @@ -64,7 +64,7 @@ class Light { } await delay_1.delay(1); try { - this.arduino.string(this.id, str); + this.arduino.sendString(this.id, str); } catch (err) { this.log.error('Error sending light string', err); diff --git a/app/lib/light/index.js.map b/app/lib/light/index.js.map index 850542d..6a4e222 100644 --- a/app/lib/light/index.js.map +++ b/app/lib/light/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/light/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,iCAA8B;AAC9B,2BAA4B;AAE5B,MAAM,KAAK;IAYV;;QAEI;IACJ,YAAa,OAAiB,EAAE,GAAS,EAAE,EAAQ;QAd5C,UAAK,GAAS,EAAE,KAAK,EAAG,CAAC,CAAC,EAAE,CAAC,E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src/arduino/index.ts @@ -105,7 +105,7 @@ class Arduino { } return this.serial[device].write(cmd, (err : any, results : any) => { if (err) { - //console.error(err) + //this.log.error(err) return reject(err) } }) @@ -115,7 +115,7 @@ class Arduino { async send (serial : string, cmd : string) { const device : any = this.alias[serial] let results : any - //console.log(`${cmd} -> ${serial}`) + //this.log.info(`${cmd} -> ${serial}`) if (this.locks[serial]) { return false } @@ -125,7 +125,7 @@ class Arduino { try { results = await this.sendAsync(device, cmd) } catch (e) { - return console.error(e) + return this.log.error(e) } this.locks[serial] = false @@ -133,7 +133,7 @@ class Arduino { return results } - async string (serial : string, str : string) { + async sendString (serial : string, str : string) : Promise { const device : any = this.alias[serial] let writeSuccess : any await delay(cfg.arduino.serialDelay) @@ -144,12 +144,48 @@ class Arduino { try { writeSuccess = await this.writeAsync(device, str) } catch (e) { - return console.error(e) + return this.log.error(e) } return writeSuccess } } + async stateAsync (device : string) : Promise { + const cmd : string = cfg.arduino.cmd.state + return new Promise ((resolve, reject) => { + this.queue[cmd] = (ms : number) => { + return resolve(ms) + } + return this.serial[device].write(cmd, (err : any, results : any) => { + if (err) { + //this.log.error(err) + return reject(err) + } + }) + }) + } + + async state (serial : string) : Promise{ + const device : any = this.alias[serial] + let results : number + + if (this.locks[serial]) { + return -1 + } + this.timer = new Date().getTime() + this.locks[serial] = true + await delay(cfg.arduino.serialDelay) + try { + results = await this.stateAsync(device) + } catch (e) { + return this.log.error(e) + } + this.locks[serial] = false + + await eventEmitter.emit('arduino_state', cfg.arduino.cmd.state) + return results + } + /** * Send a string to an Arduino using async/await * @@ -158,7 +194,7 @@ class Arduino { * * @returns {Promise} Resolves after sending **/ - async writeAsync (device : string, str : string) { + async writeAsync (device : string, str : string) : Promise { return new Promise ((resolve, reject) => { this.serial[device].write(str, function (err : any, results : any) { if (err) { @@ -169,32 +205,34 @@ class Arduino { }) } - end (serial : string, data : string) { - const end : number = new Date().getTime(); - const ms : number = end - this.timer; - let complete : any; - //console.log(`${serial} -> ${data}`); + end (serial : string, data : string) : number { + const end : number = new Date().getTime() + const ms : number = end - this.timer + let complete : any + //this.log.info(`${serial} -> ${data}`); if (this.queue[data] !== undefined) { - this.locks[serial] = false; - complete = this.queue[data](ms); //execute callback - eventEmitter.emit('arduino_end', data); - delete this.queue[data]; - } else if (data === 'E') { + this.locks[serial] = false + complete = this.queue[data](ms) //execute callback + eventEmitter.emit('arduino_end', data) + delete this.queue[data] + } else if (data[0] === cfg.arduino.cmd.state) { + complete = this.queue[data](ms) + } else if (data[0] === cfg.arduino.cmd.error) { //error state //stop sequence //throw error in ui } else { - //console.log('Received stray "' + data + '"'); //silent to user + //this.log.info('Received stray "' + data + '"') //silent to user } - return ms; + return ms } aliasSerial (serial : string, device : string) { - //this.log.info(`Making "${serial}" an alias of ${device}`); + //this.log.info(`Making "${serial}" an alias of ${device}`) this.alias[serial] = device; } - async connect (serial : string, device : string, confirm : any) { + async connect (serial : string, device : string, confirm : any) : Promise { return new Promise(async (resolve, reject) => { let connectSuccess : any this.path[serial] = device @@ -209,10 +247,10 @@ class Arduino { try { connectSuccess = await this.openArduino(device) } catch (e) { - console.error('failed to open: ' + e) + this.log.error('failed to open: ' + e) return reject(e) } - //console.log(`Opened connection with ${this.path[serial]} as ${serial}`); + //this.log.info(`Opened connection with ${this.path[serial]} as ${serial}`) if (!confirm) { this.serial[device].on('data', async (data : Buffer) => { let d = data.toString('utf8') @@ -231,7 +269,7 @@ class Arduino { } confirmEnd (data : string) { - //console.dir(data) + //this.log.info(data) if ( data === cfg.arduino.cmd.connect || data === cfg.arduino.cmd.projector_identifier || data === cfg.arduino.cmd.camera_identifier @@ -259,8 +297,8 @@ class Arduino { || data === cfg.arduino.cmd.camera_capper_projector_identifier || data === cfg.arduino.cmd.camera_capper_projectors_identifier) { - this.confirmExec(null, data); - this.confirmExec = {}; + this.confirmExec(null, data) + this.confirmExec = {} } } @@ -348,10 +386,10 @@ class Arduino { try { closeSuccess = await this.closeArduino(device) } catch (e) { - throw e; + throw e } return closeSuccess - }; + } async fakeConnect (serial : string) { const device : string = '/dev/fake' @@ -379,8 +417,8 @@ class Arduino { return true }, fake : true - }; - //console.log('Connected to fake arduino! Not real! Does not exist!'); + } + //this.log.info('Connected to fake arduino! Not real! Does not exist!') return true } diff --git a/src/globals.d.ts b/src/globals.d.ts index cb849c6..f31cbfa 100644 --- a/src/globals.d.ts +++ b/src/globals.d.ts @@ -20,12 +20,14 @@ interface Device { interface Arduino { send (id : string, cmd : string) : number; - string (id : string, str : string) : any; + sendString (id : string, str : string) : any; enumerate () : any; connect (id : string, device : Device, state : boolean) : any; verify () : any; distinguish () : any; fakeConnect ( id : string) : any; + stateAsync (device : string) : any; + state (serial: string) : number; close () : any; aliasSerial ( id : string, device : Device) : any; } diff --git a/src/light/index.ts b/src/light/index.ts index 81d8d8c..7b57921 100644 --- a/src/light/index.ts +++ b/src/light/index.ts @@ -75,7 +75,7 @@ class Light { } await delay(1); try { - this.arduino.string(this.id, str); + this.arduino.sendString(this.id, str); } catch (err) { this.log.error('Error sending light string', err); }