X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosui%2FAltosEepromManage.java;h=fe1db9c7dd62742ac93d86927765cf7d5f0ec6b5;hb=c71a145daefb86d2c1297abec68e54bd951e3adf;hp=c7efe478e5f652cf5d2d9a678fcb23cfe6840a47;hpb=eec9eb2e81535e62c52fbb2e57a2d33f88f92c1a;p=fw%2Faltos diff --git a/altosui/AltosEepromManage.java b/altosui/AltosEepromManage.java index c7efe478..fe1db9c7 100644 --- a/altosui/AltosEepromManage.java +++ b/altosui/AltosEepromManage.java @@ -44,7 +44,7 @@ public class AltosEepromManage implements ActionListener { public void finish() { if (serial_line != null) { - serial_line.flush_output(); + serial_line.flush_input(); serial_line.close(); serial_line = null; } @@ -67,14 +67,14 @@ public class AltosEepromManage implements ActionListener { public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); boolean success = e.getID() != 0; + boolean running = false; - System.out.printf("Eeprom manager action %s %d\n", cmd, e.getID()); if (cmd.equals("download")) { if (success) { - if (any_delete) + if (any_delete) { delete.start(); - else - finish(); + running = true; + } } } else if (cmd.equals("delete")) { if (success) { @@ -84,12 +84,15 @@ public class AltosEepromManage implements ActionListener { serial_line.device.toShortString(), JOptionPane.INFORMATION_MESSAGE); } - finish(); } + if (!running) + finish(); } public AltosEepromManage(JFrame given_frame) { + boolean running = false; + frame = given_frame; device = AltosDeviceDialog.show(frame, AltosDevice.product_any); @@ -103,6 +106,8 @@ public class AltosEepromManage implements ActionListener { if (!device.matchProduct(AltosDevice.product_telemetrum)) remote = true; + serial_line.set_frame(frame); + flights = new AltosEepromList(serial_line, remote); if (flights.size() == 0) { @@ -139,15 +144,15 @@ public class AltosEepromManage implements ActionListener { * Start flight log download */ - if (any_download) + if (any_download) { download.start(); - else if (any_delete) + running = true; + } + else if (any_delete) { delete.start(); - else - finish(); + running = true; + } } - } else { - finish(); } } catch (FileNotFoundException ee) { JOptionPane.showMessageDialog(frame, @@ -166,17 +171,16 @@ public class AltosEepromManage implements ActionListener { device.toShortString(), ee.getLocalizedMessage(), JOptionPane.ERROR_MESSAGE); - finish(); } catch (TimeoutException te) { JOptionPane.showMessageDialog(frame, String.format("Communications failed with \"%s\"", device.toShortString()), "Cannot open target device", JOptionPane.ERROR_MESSAGE); - finish(); } catch (InterruptedException ie) { - finish(); } + if (!running) + finish(); } } }