Make apply-config.js and get-module-state.js use read() instead of readSync()
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
const uhk = require('./uhk');
|
const uhk = require('./uhk');
|
||||||
|
|
||||||
const device = uhk.getUhkDevice();
|
(async function() {
|
||||||
const sendData = new Buffer([uhk.usbCommands.applyConfig]);
|
const device = uhk.getUhkDevice();
|
||||||
device.write(uhk.getTransferData(sendData));
|
uhk.applyConfig(device);
|
||||||
const response = Buffer.from(device.readSync());
|
})();
|
||||||
console.log(response);
|
|
||||||
|
|||||||
@@ -1,14 +1,7 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
const uhk = require('./uhk');
|
const uhk = require('./uhk');
|
||||||
const device = uhk.getUhkDevice();
|
|
||||||
|
|
||||||
function getModuleState() {
|
(async function() {
|
||||||
const payload = new Buffer([uhk.usbCommands.getModuleProperty, 1]);
|
const device = uhk.getUhkDevice();
|
||||||
console.log('Sending ', uhk.bufferToString(payload));
|
await uhk.getModuleProperty(device, 1, uhk.modulePropertyIds.protocolVersions);
|
||||||
device.write(uhk.getTransferData(payload));
|
})();
|
||||||
const receivedBuffer = device.readSync();
|
|
||||||
console.log('Received', uhk.bufferToString(receivedBuffer));
|
|
||||||
setTimeout(getModuleState, 500)
|
|
||||||
}
|
|
||||||
|
|
||||||
getModuleState();
|
|
||||||
|
|||||||
@@ -366,6 +366,10 @@ async function writeHca(device, isIso) {
|
|||||||
await uhk.launchEepromTransfer(device, uhk.eepromOperations.write, uhk.eepromTransfer.writeHardwareConfig);
|
await uhk.launchEepromTransfer(device, uhk.eepromOperations.write, uhk.eepromTransfer.writeHardwareConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getModuleProperty(device, slotId, moduleProperty) {
|
||||||
|
await writeDevice(device, [uhk.usbCommands.getModuleProperty, slotId, moduleProperty]);
|
||||||
|
}
|
||||||
|
|
||||||
uhk = exports = module.exports = moduleExports = {
|
uhk = exports = module.exports = moduleExports = {
|
||||||
bufferToString,
|
bufferToString,
|
||||||
getUint16,
|
getUint16,
|
||||||
@@ -392,6 +396,7 @@ uhk = exports = module.exports = moduleExports = {
|
|||||||
launchEepromTransfer,
|
launchEepromTransfer,
|
||||||
writeUca,
|
writeUca,
|
||||||
writeHca,
|
writeHca,
|
||||||
|
getModuleProperty,
|
||||||
usbCommands: {
|
usbCommands: {
|
||||||
getDeviceProperty : 0x00,
|
getDeviceProperty : 0x00,
|
||||||
reenumerate : 0x01,
|
reenumerate : 0x01,
|
||||||
|
|||||||
Reference in New Issue
Block a user