uci-i2c-bus/examples/queue.js

25 lines
696 B
JavaScript
Raw Normal View History

const delay = time => new Promise(res=>setTimeout(()=>res(),time))
export async function error (packet) {
// if (packet.error) {
console.log('======== error during socket server processing')
console.log(packet.error)
console.log('==========')
// }
}
export async function reply (packet) {
console.log('reply done with', packet.count)
}
export async function test (address) {
console.log('============= Queue Stress Test ============')
let packet = {cmd:'write', args:{address:address,cmd: 9, byte:1} }
for (let i = 0; i < 100 ; i++) {
packet = {cmd:'scan', count:i}
console.log('queued:', packet.count)
this.send({cmd:'scan', count:i})
}
await delay(10000)
}