Files
agent/packages/usb/get-left-firmware-version.js
2018-01-15 00:31:24 +01:00

19 lines
960 B
JavaScript
Executable File

#!/usr/bin/env node
const uhk = require('./uhk');
const device = uhk.getUhkDevice();
const sendData = new Buffer([uhk.usbCommands.getModuleProperty, uhk.moduleSlotToId.leftHalf, uhk.modulePropertyIds.protocolVersions]);
//console.log(sendData)
device.write(uhk.getTransferData(sendData));
const response = Buffer.from(device.readSync());
//console.log(response)
const moduleProtocolMajorVersion = uhk.getUint16(response, 2);
const moduleProtocolMinorVersion = uhk.getUint16(response, 4);
const moduleProtocolPatchVersion = uhk.getUint16(response, 6);
const firmwareMajorVersion = uhk.getUint16(response, 8);
const firmwareMinorVersion = uhk.getUint16(response, 10);
const firmwarePatchVersion = uhk.getUint16(response, 12);
console.log(`moduleProtocolVersion: ${moduleProtocolMajorVersion}.${moduleProtocolMinorVersion}.${moduleProtocolPatchVersion}`);
console.log(`firmwareVersion: ${firmwareMajorVersion}.${firmwareMinorVersion}.${firmwarePatchVersion}`);