From: Keith Packard Date: Mon, 21 Sep 2015 06:01:19 +0000 (+0100) Subject: altoslib: Keep downloading when a parse error occurs X-Git-Tag: 1.6.2^2~53 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=926522c6791c2a5529ea24ebd67eea45350e3526 altoslib: Keep downloading when a parse error occurs Eventually, we'll hit a block with no valid data and give up. Until then, keep going in case the flight computer glitched and wrote bad data. Signed-off-by: Keith Packard --- diff --git a/altoslib/AltosEepromDownload.java b/altoslib/AltosEepromDownload.java index c4ddb0e7..594f053f 100644 --- a/altoslib/AltosEepromDownload.java +++ b/altoslib/AltosEepromDownload.java @@ -35,7 +35,7 @@ public class AltosEepromDownload implements Runnable { AltosEepromList flights; boolean success; - ParseException parse_exception; + String parse_errors; AltosState state; private void FlushPending() throws IOException { @@ -88,6 +88,13 @@ public class AltosEepromDownload implements Runnable { } } + void LogError(String error) { + if (parse_errors != null) + parse_errors.concat(error.concat("\n")); + else + parse_errors = error; + } + void CaptureEeprom(AltosEepromChunk eechunk, int log_format) throws IOException, ParseException { boolean any_valid = false; boolean got_flight = false; @@ -98,7 +105,14 @@ public class AltosEepromDownload implements Runnable { monitor.set_serial(flights.config_data.serial); for (int i = 0; i < AltosEepromChunk.chunk_size && !done; i += record_length) { - AltosEeprom r = eechunk.eeprom(i, log_format, state); + AltosEeprom r = null; + + try { + r = eechunk.eeprom(i, log_format, state); + } catch (ParseException pe) { + LogError(pe.getMessage()); + r = null; + } if (r == null) continue; @@ -193,25 +207,25 @@ public class AltosEepromDownload implements Runnable { link.start_remote(); for (AltosEepromLog log : flights) { - parse_exception = null; + parse_errors = null; if (log.selected) { monitor.reset(); eeprom_file = null; try { CaptureLog(log); } catch (ParseException e) { - parse_exception = e; + LogError(e.getMessage()); } if (eeprom_file != null) { eeprom_file.flush(); eeprom_file.close(); } } - if (parse_exception != null) { + if (parse_errors != null) { failed = true; - monitor.show_message(String.format("Flight %d download error\n%s\nValid log data saved", + monitor.show_message(String.format("Flight %d download error. Valid log data saved\n%s", log.flight, - parse_exception.getMessage()), + parse_errors), link.name, AltosEepromMonitor.WARNING_MESSAGE); }