From 1b15911783a813e07f4b4bf802971d4fcb232bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Mon, 2 Apr 2018 17:31:27 +0200 Subject: [PATCH] Extract code to uhk.writeUca() --- packages/usb/factory-update.js | 8 +------- packages/usb/uhk.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/usb/factory-update.js b/packages/usb/factory-update.js index 0a859047..a0192a00 100755 --- a/packages/usb/factory-update.js +++ b/packages/usb/factory-update.js @@ -21,13 +21,7 @@ require('shelljs/global'); await uhk.updateFirmwares(firmwarePath); const device = uhk.getUhkDevice(); const configBuffer = fs.readFileSync(`${firmwarePath}/devices/uhk60-right/config.bin`); - console.log('write config'); - await uhk.writeConfig(device, configBuffer, false); - console.log('apply config'); - await uhk.applyConfig(device); - console.log('lanuch eeprom transfer'); - await uhk.launchEepromTransfer(device, uhk.eepromOperations.write, uhk.eepromTransfer.writeUserConfig); - + await uhk.writeUca(device, configBuffer); await uhk.writeHca(device, false); config.verbose = false; })(); diff --git a/packages/usb/uhk.js b/packages/usb/uhk.js index 127c02f8..ba0c57fa 100644 --- a/packages/usb/uhk.js +++ b/packages/usb/uhk.js @@ -330,6 +330,15 @@ async function launchEepromTransfer(device, operation, configBuffer) { } while (isBusy); }; +async function writeUca(device, configBuffer) { + console.log('write config'); + await uhk.writeConfig(device, configBuffer, false); + console.log('apply config'); + await uhk.applyConfig(device); + console.log('lanuch eeprom transfer'); + await uhk.launchEepromTransfer(device, uhk.eepromOperations.write, uhk.eepromTransfer.writeUserConfig); +} + async function writeHca(device, isIso) { const hardwareConfig = new HardwareConfiguration(); @@ -378,6 +387,7 @@ uhk = exports = module.exports = moduleExports = { writeConfig, applyConfig, launchEepromTransfer, + writeUca, writeHca, usbCommands: { getDeviceProperty : 0x00,