removed the two default mcp sockets. Make them as needed instead.

Now just pass i2c bus options through to i2c-device.
updated all packages.
master
David Kebler 2018-02-23 13:44:40 -08:00
parent 342c6f98d2
commit 5833f42464
2 changed files with 6 additions and 23 deletions

View File

@ -33,12 +33,12 @@
}, },
"@std/esm": "cjs", "@std/esm": "cjs",
"devDependencies": { "devDependencies": {
"@std/esm": "^0.20.0", "@std/esm": "^0.22.0",
"chai": "^3.5.0", "chai": "^4.1.2",
"codecov": "^1.0.1", "codecov": "^3.0.0",
"debug": "^2.6.8", "debug": "^3.1.0",
"istanbul": "^0.4.5", "istanbul": "^0.4.5",
"mocha": "^3.4.2", "mocha": "^5.0.1",
"nodemon": "^1.14.12" "nodemon": "^1.15.1"
} }
} }

View File

@ -17,14 +17,6 @@ const LOG_OPTS = (id) => {
export default class MCP230XX extends Device { export default class MCP230XX extends Device {
constructor(opts) { constructor(opts) {
if(opts.nmcp) {
if (typeof opts.nmcp.path!=='string') opts.nmcp = {path: (process.env.SOCKETS_DIR || __dirname) + '/mcp.sock'}
opts.sockets = (opts.sockets ? (opts.sockets+',') : '') + 'nmcp#s>n'
}
if(opts.tmcp) {
if (typeof opts.nmcp.port!=='number') opts.tmcp.port = 1776
opts.sockets = (opts.sockets ? (opts.sockets+',') : '') + 'tmcp#s>t'
}
super(opts) super(opts)
log = logger.child(LOG_OPTS(this.id)) log = logger.child(LOG_OPTS(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' )
@ -36,18 +28,9 @@ export default class MCP230XX extends Device {
async init(){ async init(){
await super.init() await super.init()
// let res = await this.chip.ack.bind(this)() // move this to device class
// if (!res.ack) throw `no device on this bus at address ${this.address}=0x${this.address.toString(16)}`
let res = await this.chip.cfg({}) let res = await this.chip.cfg({})
// console.log(res)
let cfg = this.chip17 ?'10100010':'00100010' let cfg = this.chip17 ?'10100010':'00100010'
if (res.response !==cfg ) throw `could not configure mcp chip at ${this.address}=0x${this.address.toString(16)}` if (res.response !==cfg ) throw `could not configure mcp chip at ${this.address}=0x${this.address.toString(16)}`
} }
// this overwrites the default cmd 'reply' from the bus
reply (packet) {
// console.log(packet._header.request, packet.response)
}
} // end of MCP230XX Class } // end of MCP230XX Class