altos: Don't try to use non-basestations for remote eeprom download
[fw/altos] / altosui / AltosEepromDelete.java
index c95eda153d5c5edc07eee944b0cd0324a7266d8d..94951ced3758c66be524b980643d394accb98fe8 100644 (file)
@@ -49,11 +49,9 @@ public class AltosEepromDelete implements Runnable {
                         */
                        serial_line.flush_input();
                        serial_line.printf("d %d\n", log.flight);
-                       System.out.printf("Attempt to delete flight %d\n", log.flight);
                        for (;;) {
                                /* It can take a while to erase the flash... */
                                String line = serial_line.get_reply(20000);
-                               System.out.printf("got back line %s\n", line);
                                if (line == null)
                                        throw new TimeoutException();
                                if (line.equals("Erased"))
@@ -86,17 +84,16 @@ public class AltosEepromDelete implements Runnable {
        }
 
        public void run () {
-               if (remote)
-                       serial_line.start_remote();
-
                success = false;
                try {
+                       if (remote)
+                               serial_line.start_remote();
+
                        for (AltosEepromLog log : flights) {
                                if (log.delete) {
                                        DeleteLog(log);
                                }
                        }
-                       System.out.printf("All flights successfully deleted\n");
                        success = true;
                } catch (IOException ee) {
                        show_error (ee.getLocalizedMessage(),
@@ -106,11 +103,12 @@ public class AltosEepromDelete implements Runnable {
                        show_error (String.format("Connection to \"%s\" failed",
                                                  serial_line.device.toShortString()),
                                    "Connection Failed");
+               } finally {
+                       if (remote)
+                               serial_line.stop_remote();
+                       serial_line.flush_output();
+                       serial_line.close();
                }
-               if (remote)
-                       serial_line.stop_remote();
-               serial_line.flush_output();
-               serial_line.close();
                if (listener != null) {
                        Runnable r = new Runnable() {
                                        public void run() {