changed options processing
makes named pipe socket listener by default add tcp listener with simple boolean for default or by giving a port numbermaster
parent
cab186f1f1
commit
8bd22e4023
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue