0.1.15 update deps, cleanup logging
parent
0f33f7c38b
commit
26e480725c
|
@ -3,3 +3,7 @@ test/
|
|||
*.test.js
|
||||
testing/
|
||||
yarn.lock
|
||||
examples/
|
||||
.eslintrc.js
|
||||
travis.yml
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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 }})
|
||||
},
|
||||
|
||||
|
|
|
@ -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)
|
||||
// TODO enable mux channel set
|
||||
// async _setChannel() {
|
||||
// }
|
||||
return Promise.resolve() // no channel for device either no mux or device is attached to mux bypass
|
||||
}
|
||||
|
||||
} // end of i2c Device Class
|
||||
|
||||
export default I2CDevice
|
||||
|
|
Loading…
Reference in New Issue