Query the combined ConfigSizes device property. Remove the deprecated HardwareConfigSize and UserConfigSize device properties.

This commit is contained in:
László Monda
2017-12-14 19:40:03 +01:00
parent cac74c7c5a
commit 3e7a0ed81a
7 changed files with 43 additions and 60 deletions

View File

@@ -1,14 +1,13 @@
#!/usr/bin/env node
const uhk = require('./uhk');
const isHardwareConfig = process.argv[2] === 'h';
const device = uhk.getUhkDevice();
const sendData = new Buffer([uhk.usbCommands.getProperty,
isHardwareConfig ?
uhk.systemPropertyIds.hardwareConfigSize
: uhk.systemPropertyIds.userConfigSize]);
const sendData = new Buffer([uhk.usbCommands.getProperty, uhk.devicePropertyIds.configSizes]);
device.write(uhk.getTransferData(sendData));
const response = Buffer.from(device.readSync());
console.log(response[1] + (response[2]<<8));
const hardwareConfigMaxSize = response[1] + (response[2]<<8);
const userConfigMaxSize = response[3] + (response[4]<<8);
console.log(`hardwareConfigMaxSize: ${hardwareConfigMaxSize}`);
console.log(`userConfigMaxSize: ${userConfigMaxSize}`);

View File

@@ -6,7 +6,7 @@ let counter = 1;
while (true) {
console.log(`hidapi sync test ${counter++}`);
const sendData = new Buffer([uhk.usbCommands.getProperty, uhk.systemPropertyIds.hardwareConfigSize]);
const sendData = new Buffer([uhk.usbCommands.getProperty, uhk.devicePropertyIds.configSizes]);
device.write(uhk.getTransferData(sendData));
device.readSync()
}

View File

@@ -6,22 +6,18 @@ const chunkSize = 63;
let isHardwareConfig = process.argv[2] === 'h';
let configTypeString = isHardwareConfig ? 'hardware' : 'user';
let configSize;
let offset = 0;
let configBuffer = new Buffer(0);
let chunkSizeToRead;
const payload = new Buffer([
uhk.usbCommands.getProperty,
isHardwareConfig
? uhk.systemPropertyIds.hardwareConfigSize
: uhk.systemPropertyIds.userConfigSize
]);
const payload = new Buffer([uhk.usbCommands.getProperty, uhk.devicePropertyIds.configSizes]);
device.write(uhk.getTransferData(payload));
let buffer = Buffer.from(device.readSync());
configSize = buffer[1] + (buffer[2]<<8);
const hardwareConfigMaxSize = buffer[1] + (buffer[2]<<8);
const userConfigMaxSize = buffer[3] + (buffer[4]<<8);
const configMaxSize = isHardwareConfig ? hardwareConfigMaxSize : userConfigMaxSize;
const configSize = Math.min(configMaxSize, configBuffer.length);
console.log(`${configTypeString}configSize:`, configSize);
while (offset < configSize) {
const configBufferId = isHardwareConfig ? uhk.configBufferIds.hardwareConfig : uhk.configBufferIds.validatedUserConfig;

View File

@@ -96,13 +96,10 @@ exports = module.exports = moduleExports = {
compatibleKeyboard: 0x6123,
},
vendorId: 0x1D50,
systemPropertyIds: {
usbProtocolVersion: 0,
bridgeProtocolVersion: 1,
dataModelVersion: 2,
firmwareVersion: 3,
hardwareConfigSize: 4,
userConfigSize: 5,
devicePropertyIds: {
deviceProtocolVersion: 0,
protocolVersions: 1,
configSizes: 2,
},
configBufferIds,
eepromOperations,

View File

@@ -19,21 +19,18 @@ const configBin = program.args[0];
const chunkSize = 60;
const isHardwareConfig = program.hardwareConfig;
const configTypeString = isHardwareConfig ? 'hardware' : 'user';
let configSize;
let offset = 0;
let configBuffer = fs.readFileSync(configBin);
let chunkSizeToRead;
const payload = new Buffer([
uhk.usbCommands.getProperty,
isHardwareConfig
? uhk.systemPropertyIds.hardwareConfigSize
: uhk.systemPropertyIds.userConfigSize
]);
const payload = new Buffer([uhk.usbCommands.getProperty, uhk.devicePropertyIds.configSizes]);
device.write(uhk.getTransferData(payload));
let buffer = Buffer.from(device.readSync());
configSize = Math.min(buffer[1] + (buffer[2]<<8), configBuffer.length);
const hardwareConfigMaxSize = buffer[1] + (buffer[2]<<8);
const userConfigMaxSize = buffer[3] + (buffer[4]<<8);
const configMaxSize = isHardwareConfig ? hardwareConfigMaxSize : userConfigMaxSize;
const configSize = Math.min(configMaxSize, configBuffer.length);
while (offset < configSize) {
const usbCommand = isHardwareConfig ? uhk.usbCommands.writeHardwareConfig : uhk.usbCommands.writeStagingUserConfig;