Change the arguments of UsbCommandId_LaunchEepromTransfer and its id to 0x08.
This commit is contained in:
@@ -16,23 +16,21 @@ export enum UsbCommand {
|
|||||||
WriteHardwareConfig = 0x05,
|
WriteHardwareConfig = 0x05,
|
||||||
WriteStagingUserConfig = 0x06,
|
WriteStagingUserConfig = 0x06,
|
||||||
ApplyConfig = 0x07,
|
ApplyConfig = 0x07,
|
||||||
LaunchEepromTransfer = 12,
|
LaunchEepromTransfer = 0x08,
|
||||||
GetKeyboardState = 16
|
GetKeyboardState = 16
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum EepromOperation {
|
||||||
|
read = 0,
|
||||||
|
write = 1
|
||||||
|
}
|
||||||
|
|
||||||
export enum ConfigBufferId {
|
export enum ConfigBufferId {
|
||||||
hardwareConfig = 0,
|
hardwareConfig = 0,
|
||||||
stagingUserConfig = 1,
|
stagingUserConfig = 1,
|
||||||
validatedUserConfig = 2
|
validatedUserConfig = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum EepromTransfer {
|
|
||||||
ReadHardwareConfig = 0,
|
|
||||||
WriteHardwareConfig = 1,
|
|
||||||
ReadUserConfig = 2,
|
|
||||||
WriteUserConfig = 3
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum SystemPropertyIds {
|
export enum SystemPropertyIds {
|
||||||
UsbProtocolVersion = 0,
|
UsbProtocolVersion = 0,
|
||||||
BridgeProtocolVersion = 1,
|
BridgeProtocolVersion = 1,
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ import { Device, devices, HID } from 'node-hid';
|
|||||||
import { LogService } from 'uhk-common';
|
import { LogService } from 'uhk-common';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
ConfigBufferId,
|
||||||
Constants,
|
Constants,
|
||||||
EepromTransfer,
|
EepromOperation,
|
||||||
enumerationModeIdToProductId,
|
enumerationModeIdToProductId,
|
||||||
EnumerationModes,
|
EnumerationModes,
|
||||||
KbootCommands,
|
KbootCommands,
|
||||||
@@ -81,8 +82,12 @@ export class UhkHidDevice {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async writeConfigToEeprom(transferType: EepromTransfer): Promise<void> {
|
public async writeUserConfigToEeprom(): Promise<void> {
|
||||||
await this.write(new Buffer([UsbCommand.LaunchEepromTransfer, transferType]));
|
await this.write(new Buffer([
|
||||||
|
UsbCommand.LaunchEepromTransfer,
|
||||||
|
EepromOperation.write,
|
||||||
|
ConfigBufferId.validatedUserConfig
|
||||||
|
]));
|
||||||
await this.waitUntilKeyboardBusy();
|
await this.waitUntilKeyboardBusy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import * as fs from 'fs';
|
|||||||
import { UhkBlhost } from './uhk-blhost';
|
import { UhkBlhost } from './uhk-blhost';
|
||||||
import { UhkHidDevice } from './uhk-hid-device';
|
import { UhkHidDevice } from './uhk-hid-device';
|
||||||
import { snooze } from './util';
|
import { snooze } from './util';
|
||||||
import { convertBufferToIntArray, EepromTransfer, getTransferBuffers, SystemPropertyIds, UsbCommand, ConfigBufferId
|
import { convertBufferToIntArray, getTransferBuffers, SystemPropertyIds, UsbCommand, ConfigBufferId
|
||||||
} from '../index';
|
} from '../index';
|
||||||
import { LoadConfigurationsResult } from './models/load-configurations-result';
|
import { LoadConfigurationsResult } from './models/load-configurations-result';
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ export class UhkOperations {
|
|||||||
this.logService.debug('[DeviceOperation] USB[T]: Write user configuration to keyboard');
|
this.logService.debug('[DeviceOperation] USB[T]: Write user configuration to keyboard');
|
||||||
await this.sendUserConfigToKeyboard(json);
|
await this.sendUserConfigToKeyboard(json);
|
||||||
this.logService.debug('[DeviceOperation] USB[T]: Write user configuration to EEPROM');
|
this.logService.debug('[DeviceOperation] USB[T]: Write user configuration to EEPROM');
|
||||||
await this.device.writeConfigToEeprom(EepromTransfer.WriteUserConfig);
|
await this.device.writeUserConfigToEeprom();
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
this.logService.error('[DeviceOperation] Transferring error', error);
|
this.logService.error('[DeviceOperation] Transferring error', error);
|
||||||
|
|||||||
@@ -2,15 +2,15 @@
|
|||||||
const uhk = require('./uhk');
|
const uhk = require('./uhk');
|
||||||
|
|
||||||
const eepromTransferType = process.argv[2];
|
const eepromTransferType = process.argv[2];
|
||||||
const eepromTransferId = uhk.eepromTransfer[eepromTransferType];
|
const eepromTransfer = uhk.eepromTransfer[eepromTransferType];
|
||||||
|
|
||||||
if (eepromTransferId === undefined) {
|
if (eepromTransfer === undefined) {
|
||||||
console.error(`Gotta provide one of ${Object.keys(uhk.eepromTransfer).join(', ')}`);
|
console.error(`Gotta provide one of ${Object.keys(uhk.eepromTransfer).join(', ')}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const device = uhk.getUhkDevice();
|
const device = uhk.getUhkDevice();
|
||||||
device.write(uhk.getTransferData(new Buffer([uhk.usbCommands.launchEepromTransferLegacy, eepromTransferId])));
|
device.write(uhk.getTransferData(new Buffer([uhk.usbCommands.launchEepromTransfer, eepromTransfer.operation, eepromTransfer.configBuffer])));
|
||||||
const buffer = Buffer.from(device.readSync());
|
const buffer = Buffer.from(device.readSync());
|
||||||
const responseCode = buffer[0];
|
const responseCode = buffer[0];
|
||||||
if (responseCode !== 0) {
|
if (responseCode !== 0) {
|
||||||
|
|||||||
@@ -44,6 +44,17 @@ function getBootloaderDevice() {
|
|||||||
return foundDevice;
|
return foundDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let configBufferIds = {
|
||||||
|
hardwareConfig: 0,
|
||||||
|
stagingUserConfig: 1,
|
||||||
|
validatedUserConfig: 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
let eepromOperations = {
|
||||||
|
read: 0,
|
||||||
|
write: 1,
|
||||||
|
};
|
||||||
|
|
||||||
exports = module.exports = moduleExports = {
|
exports = module.exports = moduleExports = {
|
||||||
bufferToString,
|
bufferToString,
|
||||||
getUhkDevice,
|
getUhkDevice,
|
||||||
@@ -59,10 +70,10 @@ exports = module.exports = moduleExports = {
|
|||||||
writeHardwareConfig : 0x05,
|
writeHardwareConfig : 0x05,
|
||||||
writeStagingUserConfig : 0x06,
|
writeStagingUserConfig : 0x06,
|
||||||
applyConfig : 0x07,
|
applyConfig : 0x07,
|
||||||
|
launchEepromTransfer : 0x08,
|
||||||
setTestLed: 0x14,
|
setTestLed: 0x14,
|
||||||
setLedPwmBrightness: 10,
|
setLedPwmBrightness: 10,
|
||||||
getAdcValue: 11,
|
getAdcValue: 11,
|
||||||
launchEepromTransferLegacy: 12,
|
|
||||||
getKeyboardState: 16,
|
getKeyboardState: 16,
|
||||||
getDebugInfo: 17,
|
getDebugInfo: 17,
|
||||||
},
|
},
|
||||||
@@ -93,16 +104,25 @@ exports = module.exports = moduleExports = {
|
|||||||
hardwareConfigSize: 4,
|
hardwareConfigSize: 4,
|
||||||
userConfigSize: 5,
|
userConfigSize: 5,
|
||||||
},
|
},
|
||||||
configBufferIds: {
|
configBufferIds,
|
||||||
hardwareConfig: 0,
|
eepromOperations,
|
||||||
stagingUserConfig: 1,
|
|
||||||
validatedUserConfig: 2,
|
|
||||||
},
|
|
||||||
eepromTransfer: {
|
eepromTransfer: {
|
||||||
readHardwareConfig: 0,
|
readHardwareConfig: {
|
||||||
writeHardwareConfig: 1,
|
operation: eepromOperations.read,
|
||||||
readUserConfig: 2,
|
configBuffer: configBufferIds.hardwareConfig,
|
||||||
writeUserConfig: 3,
|
},
|
||||||
|
writeHardwareConfig: {
|
||||||
|
operation: eepromOperations.write,
|
||||||
|
configBuffer:configBufferIds.hardwareConfig,
|
||||||
|
},
|
||||||
|
readUserConfig: {
|
||||||
|
operation: eepromOperations.read,
|
||||||
|
configBuffer: configBufferIds.validatedUserConfig,
|
||||||
|
},
|
||||||
|
writeUserConfig: {
|
||||||
|
operation: eepromOperations.write,
|
||||||
|
configBuffer: configBufferIds.validatedUserConfig,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
kbootCommands: {
|
kbootCommands: {
|
||||||
idle: 0,
|
idle: 0,
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ configSize = buffer[1] + (buffer[2]<<8);
|
|||||||
console.log(`${configTypeString}configSize:`, configSize);
|
console.log(`${configTypeString}configSize:`, configSize);
|
||||||
|
|
||||||
while (offset < configSize) {
|
while (offset < configSize) {
|
||||||
const usbCommand = isHardwareConfig ? uhk.usbCommands.writeHardwareConfig : uhk.usbCommands.writeUserConfig;
|
const usbCommand = isHardwareConfig ? uhk.usbCommands.writeHardwareConfig : uhk.usbCommands.writeStagingUserConfig;
|
||||||
chunkSizeToRead = Math.min(chunkSize, configSize - offset);
|
chunkSizeToRead = Math.min(chunkSize, configSize - offset);
|
||||||
buffer = Buffer.concat([
|
buffer = Buffer.concat([
|
||||||
new Buffer([usbCommand, chunkSizeToRead, offset & 0xff, offset >> 8]),
|
new Buffer([usbCommand, chunkSizeToRead, offset & 0xff, offset >> 8]),
|
||||||
|
|||||||
Reference in New Issue
Block a user