diff options
author | Keith Packard <keithp@keithp.com> | 2019-06-18 23:14:05 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2019-06-18 23:14:05 -0700 |
commit | bcf609837eefd431415c979942a31abda1227eb9 (patch) | |
tree | 7173b226f6f52a35406b410af8a26791aef8eb0b /altoslib/AltosEepromDownload.java | |
parent | ee7a54b3215ffa1eb38f16a151c0740b14b60857 (diff) |
altoslib: Add support for MicroPeak v2 eeprom format
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosEepromDownload.java')
-rw-r--r-- | altoslib/AltosEepromDownload.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/altoslib/AltosEepromDownload.java b/altoslib/AltosEepromDownload.java index 280414f8..f305ed33 100644 --- a/altoslib/AltosEepromDownload.java +++ b/altoslib/AltosEepromDownload.java @@ -26,6 +26,8 @@ import java.util.concurrent.*; class AltosEepromNameData extends AltosDataListener { AltosGPS gps = null; + boolean avoid_duplicate_files = false; + public void set_rssi(int rssi, int status) { } public void set_received_time(long received_time) { } @@ -39,6 +41,10 @@ class AltosEepromNameData extends AltosDataListener { public void set_apogee_voltage(double volts) { } public void set_main_voltage(double volts) { } + public void set_avoid_duplicate_files() { + avoid_duplicate_files = true; + } + public void set_gps(AltosGPS gps) { super.set_gps(gps); if (gps != null && @@ -96,12 +102,19 @@ public class AltosEepromDownload implements Runnable { private AltosFile MakeFile(int serial, int flight, AltosEepromNameData name_data) throws IOException { AltosFile eeprom_name; - if (name_data.gps != null) { - AltosGPS gps = name_data.gps; - eeprom_name = new AltosFile(gps.year, gps.month, gps.day, - serial, flight, "eeprom"); - } else - eeprom_name = new AltosFile(serial, flight, "eeprom"); + for (;;) { + if (name_data.gps != null) { + AltosGPS gps = name_data.gps; + eeprom_name = new AltosFile(gps.year, gps.month, gps.day, + serial, flight, "eeprom"); + } else + eeprom_name = new AltosFile(serial, flight, "eeprom"); + if (!name_data.avoid_duplicate_files) + break; + if (!eeprom_name.exists()) + break; + flight++; + } return eeprom_name; } |