summaryrefslogtreecommitdiff
path: root/altosui/AltosFlashUI.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-02-28 21:16:57 -0800
committerKeith Packard <keithp@keithp.com>2014-02-28 21:16:57 -0800
commita072cbb137126e677d3ebbf0245ec4ea5aa481ad (patch)
tree97ef2ce63e6ff304582972d78db2a75f613c35d7 /altosui/AltosFlashUI.java
parentac2cfb03158b4902466a72edad5dc471ee6bdb91 (diff)
altosui: Retry device enumeration after rebooting for self flash
Windows takes 'a while' to include the rebooted device in the list of available devices, so try a few times with a 100ms delay so that we can avoid asking the user to select from an empty list. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/AltosFlashUI.java')
-rw-r--r--altosui/AltosFlashUI.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java
index 5913e506..793a8af3 100644
--- a/altosui/AltosFlashUI.java
+++ b/altosui/AltosFlashUI.java
@@ -377,7 +377,15 @@ public class AltosFlashUI
while (!link.is_loader()) {
link.to_loader();
- java.util.List<AltosDevice> devices = AltosUSBDevice.list(AltosLib.product_altusmetrum);
+ java.util.List<AltosDevice> devices = null;
+
+ for (int tries = 0; tries < 10; tries++) {
+ Thread.sleep(100);
+ devices = AltosUSBDevice.list(AltosLib.product_altusmetrum);
+ if (devices.size() != 0)
+ break;
+ }
+
if (devices.size() == 1)
device = devices.get(0);
else {
@@ -429,4 +437,4 @@ public class AltosFlashUI
frame = in_frame;
}
-} \ No newline at end of file
+}