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, () => {})