From 26e480725ceeab78a3ec384410e8a75192392865 Mon Sep 17 00:00:00 2001 From: David Kebler Date: Fri, 26 Apr 2019 11:09:33 -0700 Subject: [PATCH] 0.1.15 update deps, cleanup logging --- .npmignore | 4 ++++ package.json | 6 +++--- src/bus-device-commands.js | 2 -- src/device.js | 19 +++++++------------ 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/.npmignore b/.npmignore index 17cafde..cfe164a 100644 --- a/.npmignore +++ b/.npmignore @@ -3,3 +3,7 @@ test/ *.test.js testing/ yarn.lock +examples/ +.eslintrc.js +travis.yml + diff --git a/package.json b/package.json index 1b7d438..621f101 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@uci/i2c-device", - "version": "0.1.14", + "version": "0.1.15", "description": "Device Classes for I2C Interfacing", "main": "src/device", "scripts": { @@ -26,8 +26,8 @@ }, "homepage": "https://github.com/uCOMmandIt/i2c#readme", "dependencies": { - "@uci/base": "^0.1.18", - "@uci-utils/logger": "0.0.13" + "@uci/base": "^0.1.20", + "@uci-utils/logger": "0.0.14" }, "devDependencies": { "chai": "^4.1.2", diff --git a/src/bus-device-commands.js b/src/bus-device-commands.js index e40022b..69389c8 100644 --- a/src/bus-device-commands.js +++ b/src/bus-device-commands.js @@ -35,13 +35,11 @@ export default { // both cmd and byte should be a single byte as a decimal or hex read: async function (cmd) { await this._setChannel() - // console.log('after set before read',this.address,this.id,cmd) return await this.send('bus',{ cmd:'read', args: {address:this.address, cmd:cmd }}) }, write: async function (cmd, byte) { await this._setChannel() - // console.log('after set, before write',this.address,this.id,cmd,byte) return await this.send('bus',{ cmd:'write', args: {address:this.address, cmd:cmd, byte:byte }}) }, diff --git a/src/device.js b/src/device.js index f23ca56..08bff85 100644 --- a/src/device.js +++ b/src/device.js @@ -23,7 +23,7 @@ class I2CDevice extends Base { name: 'i2c-device', id: this.id }) - if (!opts.address) log.fatal({ opts: opts }, 'no i2c bus address supplied') + if (!opts.address) log.fatal({ opts: opts, method:'constructor', line:26, msg:'no i2c bus address supplied'}) this.address = +opts.address // make sure any passed number is number not a string this._channel = +opts.channel // if using TAC9546A channel number on which device is attached this.bus = this.bindFuncs(commands) @@ -35,22 +35,17 @@ class I2CDevice extends Base { let socket = this.socket.bus.opts let connection = socket.path || socket.host + ':' + socket.port if (!res.ack) { - let err ={error:'ack', res:res, socket:socket, connection:connection, address:this.address, msg:`no bus or device on bus at address ${this.address}=0x${this.address.toString(16)}`} - log.warn(err) + let err ={error:'ack', res:res, socket:socket, method:'init', line:38, connection:connection, address:this.address, msg:`no bus or device on bus at address ${this.address}=0x${this.address.toString(16)}`} + log.error(err) return err } return res } - async _setChannel() { - // TODO convert to package - uci-mux - // console.log('before set',this.address,this.id,this._channel, await this.socket.bus.send(getState) - // if (this._channel) { - // if (!await this.socket.bus.send(address) { return Promise.reject('Channel set but no mux on bus')} - // return await this.socket.bus.send(set(this._channel) - // } - return Promise.resolve() // no channel for device either no mux or device is attached to mux bypass - } + // TODO enable mux channel set + // async _setChannel() { + // } + } // end of i2c Device Class export default I2CDevice