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

25 lines
613 B
JavaScript

/*
* 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-packet'
// const PATH = ''
;
(async () => {
let device = new Device({id:'an i2c device', address:0x27, bus:{host:'sbc'} })
device.reply = function (packet) {
console.log('for request ',packet._header)
console.log('bus response is ',packet.response)
}
console.log((await device.init()).scan)
process.kill(process.pid, 'SIGTERM')
})().catch(err => {
console.error('FATAL: UNABLE TO START SYSTEM!\n',err)
process.kill(process.pid, 'SIGTERM')
})