uci-i2c-device/examples/tcp-scan.js

25 lines
656 B
JavaScript
Raw Normal View History

2018-02-14 19:03:20 -08:00
/*
* i2c bus with both unix and tcp socket using defaults. For TCP that is host OS name and port 8080
*
*/
import Device from '../src/device'
2018-02-14 19:03:20 -08:00
// const PATH = ''
;
(async () => {
let device = new Device({id:'an i2c device', useRootNS:true, address:0x27, bus:{host:'sbc'} })
2018-02-14 19:03:20 -08:00
device.reply = function (packet) {
console.log('for request ',packet._header.request)
2018-02-14 19:03:20 -08:00
console.log('bus response is ',packet.response)
}
console.log('return from await scan', (await device.init()).scan)
2018-02-14 19:03:20 -08:00
process.kill(process.pid, 'SIGTERM')
})().catch(err => {
console.error('FATAL: UNABLE TO START SYSTEM!\n',err)
process.kill(process.pid, 'SIGTERM')
})