Jump to the bootloader without crashing.

This commit is contained in:
László Monda
2017-02-28 01:23:56 +01:00
parent 33de26b3ab
commit cae0d02dd2
2 changed files with 26 additions and 18 deletions

View File

@@ -3,6 +3,7 @@ let uhk = require('./uhk');
let timeoutMs = 10000;
let pollingIntervalMs = 100;
let jumped = false;
console.log('Trying to jump to the bootloader...');
setInterval(() => {
@@ -18,9 +19,10 @@ setInterval(() => {
process.exit(1);
}
if (uhk.getUhkDevice()) {
if (uhk.getUhkDevice() && !jumped) {
console.log('UHK found, jumping to bootloader');
uhk.sendUsbPacket(new Buffer([uhk.usbCommands.jumpToBootloader]));
uhk.sendUsbPacket(new Buffer([uhk.usbCommands.jumpToBootloader]), {noReceive:true});
jumped = true;
}
}, pollingIntervalMs);