Files
agent/packages/usb/get-device-state.js
László Monda 2702a74035 Finalize usb protocol (#515)
* Change UsbCommandId_SetTestLed from 0x02 to 0x14

* Change UsbCommandId_JumpToModuleBootloader from 0x12 to 0x02.

* Change UsbCommandId_SendKbootCommandToModule from 0x13 to 0x03.

* Replace UsbCommandId_ReadHardwareConfig and UsbCommandId_ReadUserConfig with UsbCommandId_ReadConfig.

* Change UsbCommandId_WriteHardwareConfig and UsbCommandId_WriteUserConfig to 0x05 and 0x06.

* Change UsbCommandId_ApplyConfig to 0x07.

* Change the arguments of UsbCommandId_LaunchEepromTransfer and its id to 0x08.

* Change the value of UsbCommandId_{GetDeviceState,SetTestLed,GetDebugBuffer,GetAdcValue,SetLedPwmBrightness}.

* Use firmware 6.0.0
2017-12-13 01:20:23 +01:00

19 lines
804 B
JavaScript
Executable File

#!/usr/bin/env node
const uhk = require('./uhk');
const device = uhk.getUhkDevice();
function readKeyboardState() {
const payload = new Buffer([uhk.usbCommands.getDeviceState]);
console.log('Sending ', uhk.bufferToString(payload));
device.write(uhk.getTransferData(payload));
const receivedBuffer = device.readSync();
console.log('Received', uhk.bufferToString(receivedBuffer));
const isEepromBusy = receivedBuffer[1] !== 0 ? 'yes' : 'no ';
const areHalvesMerged = receivedBuffer[2] !== 0 ? 'yes' : 'no ';
const isLeftHalfConnected = receivedBuffer[3] !== 0 ? 'yes' : 'no ';
console.log(`isEepromBusy: ${isEepromBusy} | areHalvesMerged: ${areHalvesMerged} | isLeftHalfConnected:${isLeftHalfConnected}`);
setTimeout(readKeyboardState, 500)
}
readKeyboardState();