diff --git a/src/bus-packet.mjs b/src/bus-packet.mjs index c0c0a9c..1df99fd 100644 --- a/src/bus-packet.mjs +++ b/src/bus-packet.mjs @@ -20,16 +20,17 @@ const LOG_OPTS = { export default class Bus extends Base { constructor(opts) { log = logger.child(LOG_OPTS) - // TODO make ts options when tcp:true option or tcp:port + if (opts.path) opts.ns ={path:opts.path} if(!opts.ns) opts.ns = {path: (process.env.SOCKETS_DIR || __dirname) + '/i2c-bus.sock'} opts.sockets = (opts.sockets ? (opts.sockets+',') : '') + 'ns#s>n' - if(opts.ts) { - opts.ts.port = opts.ts.port || 1776 + if(opts.tcp) { + if (typeof opts.tcp==='number') opts.ts ={port:opts.tcp} + else opts.ts ={port:1776} opts.sockets = (opts.sockets ? (opts.sockets+',') : '') + 'ts#s>t' } super(opts) log.info({opts:opts},'created bus with these opts') - console.log({opts:opts},'created bus with these opts') + console.log({opts:opts},'\n created bus with these opts') this.busnum = opts.busnum || 1 this.i2cbus = i2c.open(this.busnum, () => {}) this.bus = bus_funcs