From 96472b71f883159e3a9790b63cc1d65436d93835 Mon Sep 17 00:00:00 2001 From: David Kebler Date: Mon, 16 Sep 2019 18:17:27 -0700 Subject: [PATCH] 0.1.22 refactor bus functions so they are generated from a common function. use the uci/base processing and namespaces add a queue for bus function calls rework all the examples fix a default ID --- package.json | 2 +- src/bus.js | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 5e568c0..0ddd4ff 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ }, "dependencies": { "@uci-utils/logger": "^0.0.15", - "@uci/base": "^0.1.27", + "@uci/base": "^0.1.30", "better-try-catch": "^0.6.2", "p-queue": "^6.1.1", "pify": "^4.0.1" diff --git a/src/bus.js b/src/bus.js index b54bfa7..8a38036 100644 --- a/src/bus.js +++ b/src/bus.js @@ -10,12 +10,6 @@ let log = {} class I2CBus extends Base { constructor(opts) { - log = logger({ - name: 'i2c-bus', - id: opts.id, - file: 'src/bus.js', - class: 'Bus' - }) if (opts.path) opts.ns = { path: opts.path } if (!opts.ns) opts.ns = { path: 'i2c-bus' } opts.sockets = (opts.sockets ? opts.sockets + ',' : '') + 'ns#s>n' @@ -26,6 +20,13 @@ class I2CBus extends Base { opts.sockets = (opts.sockets ? opts.sockets + ',' : '') + 'ts#s>t' } super(opts) + this.id = opts.id || 'i2c-bus' + log = logger({ + name: 'i2c-bus', + id: this.id, + file: 'src/bus.js', + class: 'Bus' + }) log.debug({ opts: opts }, 'created bus with these opts') this.busnum = opts.busnum || 1 this.i2cbus = i2c.open(this.busnum, () => {})