Use updateDeviceFirmware(), reenumerate(), and updateModuleFirmware() in update-all-firmwares.js instead of forking processes.

This commit is contained in:
László Monda
2018-01-31 03:40:46 +01:00
parent 1b8d6949e0
commit 5c618869a2
2 changed files with 8 additions and 4 deletions

View File

@@ -255,6 +255,7 @@ async function updateModuleFirmware(i2cAddress, moduleSlotId, firmwareImage) {
device = uhk.getUhkDevice();
await uhk.sendKbootCommandToModule(device, uhk.kbootCommands.reset, i2cAddress);
await uhk.sendKbootCommandToModule(device, uhk.kbootCommands.idle, i2cAddress);
device.close();
config.verbose = false;
echo('Firmware updated successfully.');
};

View File

@@ -3,6 +3,7 @@ const program = require('commander');
const tmp = require('tmp');
const decompress = require('decompress');
const decompressTarbz = require('decompress-tarbz2');
const uhk = require('./uhk')
require('shelljs/global');
(async function() {
@@ -28,9 +29,11 @@ require('shelljs/global');
firmwarePath = tmpObj.name;
}
config.verbose = true;
exec(`${__dirname}/update-device-firmware.js ${firmwarePath}/devices/uhk60-right/firmware.hex`);
exec(`${__dirname}/reenumerate.js normalKeyboard`);
exec(`${__dirname}/update-module-firmware.js leftHalf ${firmwarePath}/modules/uhk60-left.bin`);
console.log('Updating right firmware');
await uhk.updateDeviceFirmware(`${firmwarePath}/devices/uhk60-right/firmware.hex`, 'hex');
await uhk.reenumerate('normalKeyboard');
console.log('Updating left firmware');
await uhk.updateModuleFirmware(uhk.moduleSlotToI2cAddress.leftHalf, uhk.moduleSlotToId.leftHalf, `${firmwarePath}/modules/uhk60-left.bin`);
if (program.overwriteUserConfig) {
exec(`${__dirname}/write-config.js ${firmwarePath}/devices/uhk60-right/config.bin`);
@@ -39,7 +42,7 @@ require('shelljs/global');
}
config.verbose = false;
} catch(exception) {
} catch (exception) {
console.error(exception.message);
exit(1);
}