little cleanup update dependencies
parent
fc066e773a
commit
5e2ee6daf2
|
@ -26,8 +26,8 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/uCOMmandIt/i2c#readme",
|
"homepage": "https://github.com/uCOMmandIt/i2c#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@uci/base": "^0.1.7",
|
"@uci/base": "^0.1.8",
|
||||||
"@uci/logger": "0.0.3"
|
"@uci/logger": "0.0.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^4.1.2",
|
"chai": "^4.1.2",
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
/node_modules/
|
|
|
@ -5,21 +5,24 @@ import commands from './bus-device-commands'
|
||||||
import logger from '@uci/logger'
|
import logger from '@uci/logger'
|
||||||
let log = {}
|
let log = {}
|
||||||
|
|
||||||
export default class Device extends Base {
|
class I2CDevice extends Base {
|
||||||
constructor(opts) {
|
constructor(opts) {
|
||||||
opts.bus = opts.bus || {}
|
opts.bus = opts.bus || {}
|
||||||
if (opts.bus.host || opts.host) {
|
if (opts.bus.host || opts.host) {
|
||||||
opts.bus.host = opts.host || opts.bus.host,
|
(opts.bus.host = opts.host || opts.bus.host),
|
||||||
opts.bus.port = opts.bus.port || opts.port || 1776
|
(opts.bus.port = opts.bus.port || opts.port || 1776)
|
||||||
opts.sockets = (opts.sockets ? (opts.sockets + ',') : '') + 'bus#c>t'
|
opts.sockets = (opts.sockets ? opts.sockets + ',' : '') + 'bus#c>t'
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
opts.bus.path = opts.bus.path || opts.path || 'i2c-bus'
|
opts.bus.path = opts.bus.path || opts.path || 'i2c-bus'
|
||||||
opts.sockets = (opts.sockets ? (opts.sockets + ',') : '') + 'bus#c>n'
|
opts.sockets = (opts.sockets ? opts.sockets + ',' : '') + 'bus#c>n'
|
||||||
}
|
}
|
||||||
super(opts)
|
super(opts)
|
||||||
// console.log('created i2c device with these options\n', opts)
|
log = logger({
|
||||||
log = logger({file:'src/device-packet.js',class:'Device',name:'i2c-device',id:this.id})
|
file: 'src/device-packet.js',
|
||||||
|
class: 'Device',
|
||||||
|
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 }, 'no i2c bus address supplied')
|
||||||
this.address = opts.address
|
this.address = opts.address
|
||||||
this._channel = opts.channel // if using TAC9546A channel number on which device is attached
|
this._channel = opts.channel // if using TAC9546A channel number on which device is attached
|
||||||
|
@ -31,7 +34,12 @@ export default class Device extends Base {
|
||||||
let res = await this.bus.ack()
|
let res = await this.bus.ack()
|
||||||
let socket = this.socket.bus.opts
|
let socket = this.socket.bus.opts
|
||||||
let connection = socket.path || socket.host + ':' + socket.port
|
let connection = socket.path || socket.host + ':' + socket.port
|
||||||
if (!res.ack) throw `no device operational on bus '${socket.id}' (${connection}) at address ${this.address}=0x${this.address.toString(16)}`
|
if (!res.ack)
|
||||||
|
throw `no device operational on bus '${
|
||||||
|
socket.id
|
||||||
|
}' (${connection}) at address ${this.address}=0x${this.address.toString(
|
||||||
|
16
|
||||||
|
)}`
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +52,6 @@ export default class Device extends Base {
|
||||||
// }
|
// }
|
||||||
return Promise.resolve() // no channel for device either no mux or device is attached to mux bypass
|
return Promise.resolve() // no channel for device either no mux or device is attached to mux bypass
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // end of i2c Device Class
|
} // end of i2c Device Class
|
||||||
|
|
||||||
|
export default I2CDevice
|
||||||
|
|
Loading…
Reference in New Issue