/* * A tcp customer/client to talk with the i2c bus and scan the bus for devices * */ 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.bus.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:'rw', bus:{func:'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) })