Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/betaflight/betaflight-configurator.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhaslinghuis <mark@numloq.nl>2022-02-28 12:49:57 +0300
committerGitHub <noreply@github.com>2022-02-28 12:49:57 +0300
commita8a9ac6b6a64df4aa9cbb22a891b667c41356504 (patch)
treeb6093501bb406ab68bc037587994045f58acf9ab
parent989816a2e121702aafd0092ed7e2a94ce7b218f1 (diff)
parent249345bedab6b1aa9d2d1a3e226a2935d6a42c63 (diff)
Merge pull request #2836 from ctzsnooze/check-every-100ms-for-dfu-mode-when-flashing
check every 100ms for DFU mode
-rw-r--r--src/js/protocols/stm32.js24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/js/protocols/stm32.js b/src/js/protocols/stm32.js
index 7f2c31bb..f71d2afc 100644
--- a/src/js/protocols/stm32.js
+++ b/src/js/protocols/stm32.js
@@ -114,10 +114,26 @@ STM32_protocol.prototype.connect = function (port, baud, hex, options, callback)
const onDisconnect = disconnectionResult => {
if (disconnectionResult) {
- // delay to allow board to boot in bootloader mode
- // required to detect if a DFU device appears
- // MacOs seems to need about 5 seconds delay
- setTimeout(startFlashing, GUI.operating_system === 'MacOS' ? 5000 : 1000);
+ // wait until board boots into bootloader mode
+ // MacOs may need 5 seconds delay
+ function waitForDfu() {
+ if (PortHandler.dfu_available) {
+ console.log(`DFU available after ${failedAttempts / 10} seconds`);
+ clearInterval(dfuWaitInterval);
+ startFlashing();
+ } else {
+ failedAttempts++;
+ if (failedAttempts > 100) {
+ clearInterval(dfuWaitInterval);
+ console.log(`failed to get DFU connection, gave up after 10 seconds`);
+ GUI.log(i18n.getMessage('serialPortOpenFail'));
+ GUI.connect_lock = false;
+ }
+ }
+ }
+
+ let failedAttempts = 0;
+ const dfuWaitInterval = setInterval(waitForDfu, 100);
} else {
GUI.connect_lock = false;
}