Clean up get-left-firmware-version.js a bit.

This commit is contained in:
László Monda
2018-01-15 00:31:24 +01:00
parent 1aeb4e8326
commit 9089f088b6
2 changed files with 8 additions and 9 deletions

View File

@@ -3,10 +3,10 @@ const uhk = require('./uhk');
const device = uhk.getUhkDevice();
const sendData = new Buffer([uhk.usbCommands.getModuleProperty, uhk.moduleSlotToId.leftHalf, uhk.modulePropertyIds.protocolVersions]);
console.log(sendData)
//console.log(sendData)
device.write(uhk.getTransferData(sendData));
const response = Buffer.from(device.readSync());
console.log(response)
//console.log(response)
const moduleProtocolMajorVersion = uhk.getUint16(response, 2);
const moduleProtocolMinorVersion = uhk.getUint16(response, 4);
const moduleProtocolPatchVersion = uhk.getUint16(response, 6);

View File

@@ -3,13 +3,12 @@ const uhk = require('./uhk');
const device = uhk.getUhkDevice();
const sendData = new Buffer([uhk.usbCommands.getDeviceProperty, uhk.devicePropertyIds.protocolVersions]);
//console.log(sendData)
device.write(uhk.getTransferData(sendData));
const response = Buffer.from(device.readSync());
//console.log(response)
const firmwareMajorVersion = uhk.getUint16(response, 1);
const firmwareMinorVersion = uhk.getUint16(response, 3);
const firmwarePatchVersion = uhk.getUint16(response, 5);
const firmwareMajorVersion = response[1] + (response[2]<<8);
const firmwareMinorVersion = response[3] + (response[4]<<8);
const firmwarePatchVersion = response[5] + (response[6]<<8);
console.log(`firmwareMajorVersion: ${firmwareMajorVersion}`);
console.log(`firmwareMinorVersion: ${firmwareMinorVersion}`);
console.log(`firmwarePatchVersion: ${firmwarePatchVersion}`);
console.log(`firmwareVersion: ${firmwareMajorVersion}.${firmwareMinorVersion}.${firmwarePatchVersion}`);