/* * A tcp customer/client to talk with the i2c bus and scan the bus for devices * */ import Base from '../../uci-base/src/base' const HOST = 'sbc' const delay = time => new Promise(res=>setTimeout(()=>res(),time)) ; (async () => { let scanner = new Base({id:'tcp-i2c-client', sockets:'tc', host:HOST}) scanner.reply = function (packet) { let addresses = packet.response.map(device => { return device.toString(16)}) // console.log(packet) console.log('==== device hex addreses on i2cbus ===\n',addresses) } await scanner.init() console.log('=============sending============') let packet = {cmd:'scan'} console.dir(packet) await scanner.send(packet) await delay(3000) process.kill(process.pid, 'SIGTERM') })().catch(err => { console.error('FATAL: UNABLE TO START SYSTEM!\n',err) })