diff --git a/packages/usb/uhk.js b/packages/usb/uhk.js index 10309fd4..73868b54 100644 --- a/packages/usb/uhk.js +++ b/packages/usb/uhk.js @@ -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.'); }; diff --git a/packages/usb/update-all-firmwares.js b/packages/usb/update-all-firmwares.js index e7097324..41ecea0f 100755 --- a/packages/usb/update-all-firmwares.js +++ b/packages/usb/update-all-firmwares.js @@ -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); }