Move getBlhostCmd() from shared.js to uhk.js
This commit is contained in:
@@ -1,27 +1,5 @@
|
|||||||
require('shelljs/global');
|
require('shelljs/global');
|
||||||
|
|
||||||
function getBlhostCmd(pid) {
|
|
||||||
let blhostPath;
|
|
||||||
switch (process.platform) {
|
|
||||||
case 'linux':
|
|
||||||
const arch = exec('uname -m', {silent:true}).stdout.trim();
|
|
||||||
blhostPath = `linux/${arch}/blhost`;
|
|
||||||
break;
|
|
||||||
case 'darwin':
|
|
||||||
blhostPath = 'mac/blhost';
|
|
||||||
break;
|
|
||||||
case 'win32':
|
|
||||||
blhostPath = 'win/blhost.exe';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
echo('Your operating system is not supported.');
|
|
||||||
exit(1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${__dirname}/blhost/${blhostPath} --usb 0x1d50,0x${pid.toString(16)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function execRetry(command) {
|
function execRetry(command) {
|
||||||
let firstRun = true;
|
let firstRun = true;
|
||||||
let remainingRetries = 3;
|
let remainingRetries = 3;
|
||||||
@@ -38,7 +16,6 @@ function execRetry(command) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const exp = {
|
const exp = {
|
||||||
getBlhostCmd,
|
|
||||||
execRetry,
|
execRetry,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,28 @@ function checkFirmwareImage(imagePath, extension) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getBlhostCmd(pid) {
|
||||||
|
let blhostPath;
|
||||||
|
switch (process.platform) {
|
||||||
|
case 'linux':
|
||||||
|
const arch = exec('uname -m', {silent:true}).stdout.trim();
|
||||||
|
blhostPath = `linux/${arch}/blhost`;
|
||||||
|
break;
|
||||||
|
case 'darwin':
|
||||||
|
blhostPath = 'mac/blhost';
|
||||||
|
break;
|
||||||
|
case 'win32':
|
||||||
|
blhostPath = 'win/blhost.exe';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
echo('Your operating system is not supported.');
|
||||||
|
exit(1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${__dirname}/blhost/${blhostPath} --usb 0x1d50,0x${pid.toString(16)}`;
|
||||||
|
}
|
||||||
|
|
||||||
let configBufferIds = {
|
let configBufferIds = {
|
||||||
hardwareConfig: 0,
|
hardwareConfig: 0,
|
||||||
stagingUserConfig: 1,
|
stagingUserConfig: 1,
|
||||||
@@ -153,6 +175,7 @@ exports = module.exports = moduleExports = {
|
|||||||
getTransferData,
|
getTransferData,
|
||||||
checkModuleSlot,
|
checkModuleSlot,
|
||||||
checkFirmwareImage,
|
checkFirmwareImage,
|
||||||
|
getBlhostCmd,
|
||||||
reenumerate,
|
reenumerate,
|
||||||
usbCommands: {
|
usbCommands: {
|
||||||
getDeviceProperty : 0x00,
|
getDeviceProperty : 0x00,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ program
|
|||||||
|
|
||||||
const firmwareImage = program.args[0];
|
const firmwareImage = program.args[0];
|
||||||
const usbDir = `${__dirname}`;
|
const usbDir = `${__dirname}`;
|
||||||
const blhost = getBlhostCmd(uhk.enumerationNameToProductId.bootloader);
|
const blhost = uhk.getBlhostCmd(uhk.enumerationNameToProductId.bootloader);
|
||||||
|
|
||||||
uhk.checkFirmwareImage(firmwareImage, extension);
|
uhk.checkFirmwareImage(firmwareImage, extension);
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const firmwareImage = program.args[1];
|
|||||||
uhk.checkFirmwareImage(firmwareImage, extension);
|
uhk.checkFirmwareImage(firmwareImage, extension);
|
||||||
|
|
||||||
const usbDir = `${__dirname}`;
|
const usbDir = `${__dirname}`;
|
||||||
const blhostUsb = getBlhostCmd(uhk.enumerationNameToProductId.buspal);
|
const blhostUsb = uhk.getBlhostCmd(uhk.enumerationNameToProductId.buspal);
|
||||||
const blhostBuspal = `${blhostUsb} --buspal i2c,${i2cAddress}`;
|
const blhostBuspal = `${blhostUsb} --buspal i2c,${i2cAddress}`;
|
||||||
|
|
||||||
config.verbose = true;
|
config.verbose = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user