From e196083d5ea7392c0b945995baaf25d21c3e1ae7 Mon Sep 17 00:00:00 2001 From: David Kebler Date: Tue, 31 Jul 2018 17:28:02 -0700 Subject: [PATCH] add conPacket to each socket using the resetCmd option for the command and included the pin: key so the port can be looked up --- package.json | 2 +- src/interrupt.js | 10 ++-------- src/interrupts.js | 1 + 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 915f5bf..25cfcaa 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@uci/interrupt", "main": "src", - "version": "0.1.9", + "version": "0.2.1", "description": "a class for adding interrupt processesing for gpio pins on Raspberry Pi and Similar SBCs", "scripts": { "single": "sudo node -r esm examples/single", diff --git a/src/interrupt.js b/src/interrupt.js index 7e10dd7..d9743a4 100644 --- a/src/interrupt.js +++ b/src/interrupt.js @@ -10,10 +10,10 @@ let log = {} export default class Interrupt extends Base { constructor(pin,opts={}) { - if (opts.path || opts.itrn ) { opts.itrn = opts.itrn || {} opts.itrn.path = opts.path || opts.itrn.path || 'interrupt:'+ pin + opts.itrn.conPacket = opts.conPacket opts.sockets = (opts.sockets ? (opts.sockets + ',') : '') + 'itrn#s>n' } if (opts.topics || opts.itrm) { @@ -30,6 +30,7 @@ export default class Interrupt extends Base { if (opts.itrt || opts.port || !opts.sockets) { opts.itrt = opts.itrt || {} opts.itrt.port = opts.itrt.port || opts.port || 9000+pin + opts.itrt.conPacket = opts.conPacket opts.sockets = (opts.sockets ? (opts.sockets + ',') : '') + 'itrt#s>t' } super(opts) @@ -70,13 +71,6 @@ export default class Interrupt extends Base { this.exit().then((resp) => console.log('\n', resp)) // unexport on cntrl-c .catch(err => console.log('error:', err)) }) - // const pinDebounce = function (processor, wait, options, packet) { - // console.log(processor,wait,options,packet) - // return debounce.bind(this,processor.bind(this,packet),wait, options) - // return debounce.bind(processor.bind(this,packet),wait) - // return debounce.bind(null,processor,{ wait:wait}) - // } - // else cb = pinDebounce(this.interruptProcess,this.wait,this.dbopts,this.packet) let cb = () => {} if (this.wait===0) { diff --git a/src/interrupts.js b/src/interrupts.js index 8604a8e..156e1d7 100644 --- a/src/interrupts.js +++ b/src/interrupts.js @@ -17,6 +17,7 @@ export default class Interrupts { pins.forEach (pin =>{ pinopts[pin] = Object.assign({}, opts, pinopts[pin]) pinopts[pin].id = (opts.id ||'interrupt') + ':' + pin + pinopts[pin].conPacket = { cmd:opts.resetCmd, pin:pin } log.info({opts:pinopts[pin]},`pin options for pin ${pin}`) this.interrupt[pin] = new Interrupt(pin,pinopts[pin]) })