X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosui%2FAltosFlashUI.java;h=793a8af3d156dd142c5b8724a486fb71ca99e032;hb=6dad9ca543fbed3f849b01300224b1b21ef2eb08;hp=e305d458a171fa388aa0ee2c1cfcfc286f1c9f63;hpb=c1711890c002fe359bd6c3fdf4092b35d464c6d9;p=fw%2Faltos diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java index e305d458..793a8af3 100644 --- a/altosui/AltosFlashUI.java +++ b/altosui/AltosFlashUI.java @@ -23,7 +23,7 @@ import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib_2.*; +import org.altusmetrum.altoslib_3.*; import org.altusmetrum.altosuilib_1.*; public class AltosFlashUI @@ -365,7 +365,7 @@ public class AltosFlashUI flash_task flasher; - private boolean open_device() { + private boolean open_device() throws InterruptedException { try { link = new AltosSerial(device); if (is_pair_programmed()) @@ -377,7 +377,15 @@ public class AltosFlashUI while (!link.is_loader()) { link.to_loader(); - java.util.List devices = AltosUSBDevice.list(AltosLib.product_altusmetrum); + java.util.List 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 { @@ -408,8 +416,12 @@ public class AltosFlashUI return; if (!select_source_file()) return; - if (!open_device()) + try { + if (!open_device()) + return; + } catch (InterruptedException ie) { return; + } build_dialog(); flash_task f = new flash_task(this); } @@ -425,4 +437,4 @@ public class AltosFlashUI frame = in_frame; } -} \ No newline at end of file +}