X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltosEepromDelete.java;h=cd9abfabc02fcf3b00e25f8324cb9f35ca6bd67c;hp=c95eda153d5c5edc07eee944b0cd0324a7266d8d;hb=3ba7b6196f68078f4ed4538c4e7fe30699dfe908;hpb=8801b8c1947bd39f7c985b91a2ba8dbc81bcc91a diff --git a/altosui/AltosEepromDelete.java b/altosui/AltosEepromDelete.java index c95eda15..cd9abfab 100644 --- a/altosui/AltosEepromDelete.java +++ b/altosui/AltosEepromDelete.java @@ -42,18 +42,16 @@ public class AltosEepromDelete implements Runnable { private void DeleteLog (AltosEepromLog log) throws IOException, InterruptedException, TimeoutException { - if (flights.config_data.flight_log_max != 0) { + if (flights.config_data.flight_log_max != 0 || flights.config_data.log_format != 0) { /* Devices with newer firmware can erase the * flash blocks containing each flight */ 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() {