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
javax.swing.filechooser.FileFilter ihx_filter = new FileNameExtensionFilter("Flash Image", "ihx");
hexfile_chooser.addChoosableFileFilter(ihx_filter);
hexfile_chooser.setFileFilter(ihx_filter);
-
+
if (!is_pair_programmed() && !device.matchProduct(AltosLib.product_altusmetrum)) {
for (int i = 0; i < filters.length; i++) {
if (device != null && device.matchProduct(filters[i].product))
if (file == null)
return false;
AltosUIPreferences.set_firmwaredir(file.getParentFile());
-
+
return true;
}
flash_task flasher;
- private boolean open_device() {
+ private boolean open_device() throws InterruptedException {
try {
link = new AltosSerial(device);
if (is_pair_programmed())
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 {
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);
}
frame = in_frame;
}
-}
\ No newline at end of file
+}