Bump java lib versions in preparation for 1.9.2
[fw/altos] / altosuilib / AltosFlashUI.java
index 37ab96614af52f73d4ab116aa9c39f9d457f480e..e61b397337c8b35828e7397746496fabe2764109 100644 (file)
@@ -16,7 +16,7 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-package org.altusmetrum.altosuilib_13;
+package org.altusmetrum.altosuilib_14;
 
 import java.awt.*;
 import java.awt.event.*;
@@ -24,7 +24,7 @@ import javax.swing.*;
 import javax.swing.filechooser.FileNameExtensionFilter;
 import java.io.*;
 import java.util.concurrent.*;
-import org.altusmetrum.altoslib_13.*;
+import org.altusmetrum.altoslib_14.*;
 
 public class AltosFlashUI
        extends AltosUIDialog
@@ -481,12 +481,24 @@ public class AltosFlashUI
                public void run () {
                        try {
                                AltosLink link = null;
+                               boolean new_device = false;
 
                                for (;;) {
                                        System.out.printf("Attempting to open %s\n", device.toShortString());
 
-                                       link = new AltosSerial(device);
+                                       for (int i = 0; i < 20; i++) {
+                                               link = new AltosSerial(device);
 
+                                               if (link != null)
+                                                       break;
+
+                                               if (!new_device)
+                                                       break;
+
+                                               System.out.printf("Waiting for device to become ready\n");
+
+                                               Thread.sleep(1000);
+                                       }
                                        if (link == null)
                                                throw new IOException(String.format("%s: open failed",
                                                                                    device.toShortString()));
@@ -536,6 +548,7 @@ public class AltosFlashUI
                                                        if (!matched) {
                                                                System.out.printf("Identified new device %s\n", d.toShortString());
                                                                device = (AltosUSBDevice) d;
+                                                               new_device = true;
                                                                break;
                                                        }
                                                }