Extract uhk.applyConfig() and uhk.launchEepromTransfer()

This commit is contained in:
László Monda
2018-04-01 23:55:40 +02:00
parent f9b7260be6
commit b9c32b46a9
4 changed files with 26 additions and 26 deletions

View File

@@ -276,7 +276,7 @@ async function updateFirmwares(firmwarePath) {
await uhk.updateModuleFirmware(uhk.moduleSlotToI2cAddress.leftHalf, uhk.moduleSlotToId.leftHalf, `${firmwarePath}/modules/uhk60-left.bin`);
}
async function writeUserConfig(device, configBuffer, isHardwareConfig) {
async function writeConfig(device, configBuffer, isHardwareConfig) {
const chunkSize = 60;
let offset = 0;
let chunkSizeToRead;
@@ -303,6 +303,19 @@ async function writeUserConfig(device, configBuffer, isHardwareConfig) {
}
}
async function applyConfig(device) {
await uhk.writeDevice(device, [uhk.usbCommands.applyConfig]);
}
async function launchEepromTransfer(device, operation, configBuffer) {
const buffer = await uhk.writeDevice(device, [uhk.usbCommands.launchEepromTransfer, operation, configBuffer]);
isBusy = true;
do {
const buffer = uhk.writeDevice(device, [uhk.usbCommands.getDeviceState]);
isBusy = buffer[1] === 1;
} while (isBusy);
};
uhk = exports = module.exports = moduleExports = {
bufferToString,
getUint16,
@@ -324,7 +337,9 @@ uhk = exports = module.exports = moduleExports = {
waitForKbootIdle,
updateModuleFirmware,
updateFirmwares,
writeUserConfig,
writeConfig,
applyConfig,
launchEepromTransfer,
usbCommands: {
getDeviceProperty : 0x00,
reenumerate : 0x01,