Move checkFirmwareImage() from shared.js to uhk.js
This commit is contained in:
@@ -1,22 +1,5 @@
|
|||||||
require('shelljs/global');
|
require('shelljs/global');
|
||||||
|
|
||||||
function checkFirmwareImage(imagePath, extension) {
|
|
||||||
if (!imagePath) {
|
|
||||||
echo('No firmware image specified.');
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!imagePath.endsWith(extension)) {
|
|
||||||
echo(`Firmware image extension is not ${extension}`);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!test('-f', imagePath)) {
|
|
||||||
echo('Firmware image does not exist.');
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getBlhostCmd(pid) {
|
function getBlhostCmd(pid) {
|
||||||
let blhostPath;
|
let blhostPath;
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
@@ -55,7 +38,6 @@ function execRetry(command) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const exp = {
|
const exp = {
|
||||||
checkFirmwareImage,
|
|
||||||
getBlhostCmd,
|
getBlhostCmd,
|
||||||
execRetry,
|
execRetry,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,23 @@ function getBootloaderDevice() {
|
|||||||
return foundDevice;
|
return foundDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkFirmwareImage(imagePath, extension) {
|
||||||
|
if (!imagePath) {
|
||||||
|
echo('No firmware image specified.');
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!imagePath.endsWith(extension)) {
|
||||||
|
echo(`Firmware image extension is not ${extension}`);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!test('-f', imagePath)) {
|
||||||
|
echo('Firmware image does not exist.');
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let configBufferIds = {
|
let configBufferIds = {
|
||||||
hardwareConfig: 0,
|
hardwareConfig: 0,
|
||||||
stagingUserConfig: 1,
|
stagingUserConfig: 1,
|
||||||
@@ -135,6 +152,7 @@ exports = module.exports = moduleExports = {
|
|||||||
getBootloaderDevice,
|
getBootloaderDevice,
|
||||||
getTransferData,
|
getTransferData,
|
||||||
checkModuleSlot,
|
checkModuleSlot,
|
||||||
|
checkFirmwareImage,
|
||||||
reenumerate,
|
reenumerate,
|
||||||
usbCommands: {
|
usbCommands: {
|
||||||
getDeviceProperty : 0x00,
|
getDeviceProperty : 0x00,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const firmwareImage = program.args[0];
|
|||||||
const usbDir = `${__dirname}`;
|
const usbDir = `${__dirname}`;
|
||||||
const blhost = getBlhostCmd(uhk.enumerationNameToProductId.bootloader);
|
const blhost = getBlhostCmd(uhk.enumerationNameToProductId.bootloader);
|
||||||
|
|
||||||
checkFirmwareImage(firmwareImage, extension);
|
uhk.checkFirmwareImage(firmwareImage, extension);
|
||||||
|
|
||||||
(async function() {
|
(async function() {
|
||||||
config.verbose = true;
|
config.verbose = true;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ let moduleSlot = program.args[0];
|
|||||||
const i2cAddress = uhk.checkModuleSlot(moduleSlot, uhk.moduleSlotToI2cAddress);
|
const i2cAddress = uhk.checkModuleSlot(moduleSlot, uhk.moduleSlotToI2cAddress);
|
||||||
|
|
||||||
const firmwareImage = program.args[1];
|
const firmwareImage = program.args[1];
|
||||||
checkFirmwareImage(firmwareImage, extension);
|
uhk.checkFirmwareImage(firmwareImage, extension);
|
||||||
|
|
||||||
const usbDir = `${__dirname}`;
|
const usbDir = `${__dirname}`;
|
||||||
const blhostUsb = getBlhostCmd(uhk.enumerationNameToProductId.buspal);
|
const blhostUsb = getBlhostCmd(uhk.enumerationNameToProductId.buspal);
|
||||||
|
|||||||
Reference in New Issue
Block a user