Make the bootloader timeout of the reenumerate script specifiable.

This commit is contained in:
László Monda
2018-05-16 23:19:36 +02:00
parent 17693ec8fe
commit eb97dd844f
5 changed files with 10 additions and 11 deletions

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "uhk-agent", "name": "uhk-agent",
"version": "1.2.0", "version": "1.2.1",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@@ -1,14 +1,11 @@
{ {
"name": "uhk-usb",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true, "requires": true,
"lockfileVersion": 1,
"dependencies": { "dependencies": {
"@types/node": { "@types/node": {
"version": "8.0.28", "version": "8.0.28",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.28.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.28.tgz",
"integrity": "sha512-HupkFXEv3O3KSzcr3Ylfajg0kaerBg1DyaZzRBBQfrU3NN1mTBRE7sCveqHwXLS5Yrjvww8qFzkzYQQakG9FuQ==", "integrity": "sha512-HupkFXEv3O3KSzcr3Ylfajg0kaerBg1DyaZzRBBQfrU3NN1mTBRE7sCveqHwXLS5Yrjvww8qFzkzYQQakG9FuQ=="
"dev": true
}, },
"ansi-regex": { "ansi-regex": {
"version": "2.1.1", "version": "2.1.1",

View File

@@ -1,4 +1,4 @@
import { cloneDeep, isEqual } from 'lodash-es'; import { cloneDeep, isEqual } from 'lodash';
import { Device, devices, HID } from 'node-hid'; import { Device, devices, HID } from 'node-hid';
import { CommandLineArgs, LogService } from 'uhk-common'; import { CommandLineArgs, LogService } from 'uhk-common';

View File

@@ -2,9 +2,12 @@
const uhk = require('./uhk'); const uhk = require('./uhk');
const program = require('commander'); const program = require('commander');
program.parse(process.argv); program
.option('-t, --timeout <ms>', 'Bootloader timeout in ms', 5000)
.parse(process.argv);
const enumerationMode = program.args[0]; const enumerationMode = program.args[0];
(async function() { (async function() {
await uhk.reenumerate(enumerationMode); await uhk.reenumerate(enumerationMode, program.timeout);
})(); })();

View File

@@ -191,8 +191,7 @@ async function updateDeviceFirmware(firmwareImage, extension) {
// USB commands // USB commands
function reenumerate(enumerationMode) { function reenumerate(enumerationMode, bootloaderTimeoutMs=5000) {
const bootloaderTimeoutMs = 5000;
const pollingIntervalMs = 100; const pollingIntervalMs = 100;
let pollingTimeoutMs = 10000; let pollingTimeoutMs = 10000;