Make apply-config.js and get-module-state.js use read() instead of readSync()

This commit is contained in:
László Monda
2018-04-02 22:56:28 +02:00
parent 9fcce9234a
commit 44639bbf53
3 changed files with 13 additions and 16 deletions

View File

@@ -1,14 +1,7 @@
#!/usr/bin/env node
const uhk = require('./uhk');
const device = uhk.getUhkDevice();
function getModuleState() {
const payload = new Buffer([uhk.usbCommands.getModuleProperty, 1]);
console.log('Sending ', uhk.bufferToString(payload));
device.write(uhk.getTransferData(payload));
const receivedBuffer = device.readSync();
console.log('Received', uhk.bufferToString(receivedBuffer));
setTimeout(getModuleState, 500)
}
getModuleState();
(async function() {
const device = uhk.getUhkDevice();
await uhk.getModuleProperty(device, 1, uhk.modulePropertyIds.protocolVersions);
})();