Windows appears to report the new device path long before
the path is actually usable. Stick some long delays trying to
open the device before giving up.
Signed-off-by: Keith Packard <keithp@keithp.com>
public void run () {
try {
AltosLink link = null;
public void run () {
try {
AltosLink link = null;
+ boolean new_device = false;
for (;;) {
System.out.printf("Attempting to open %s\n", device.toShortString());
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()));
if (link == null)
throw new IOException(String.format("%s: open failed",
device.toShortString()));
if (!matched) {
System.out.printf("Identified new device %s\n", d.toShortString());
device = (AltosUSBDevice) d;
if (!matched) {
System.out.printf("Identified new device %s\n", d.toShortString());
device = (AltosUSBDevice) d;