diff options
| author | Keith Packard <keithp@keithp.com> | 2017-11-11 20:49:20 -0800 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2017-11-11 20:49:20 -0800 | 
| commit | 9a7b4f02ad32ca43a45ed9fe446b8db96e60b5e5 (patch) | |
| tree | af009a016229cb6e377bc5d4cecd92874c89a839 /altoslib/AltosEepromDownload.java | |
| parent | 10834eb60f7a44fee159d9e9ad5ffb2e013fe9cf (diff) | |
altoslib: Improve EEprom download
* Catch and report CRC errors
* Deal with corrupted flight records
* Add ability to immediately graph new data
* Check before overwriting existing files
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosEepromDownload.java')
| -rw-r--r-- | altoslib/AltosEepromDownload.java | 42 | 
1 files changed, 32 insertions, 10 deletions
diff --git a/altoslib/AltosEepromDownload.java b/altoslib/AltosEepromDownload.java index 3df8a5b4..547b523f 100644 --- a/altoslib/AltosEepromDownload.java +++ b/altoslib/AltosEepromDownload.java @@ -200,25 +200,47 @@ public class AltosEepromDownload implements Runnable {  		AltosFile f = MakeFile(flights.config_data.serial, log.flight, name_data); -		monitor.set_filename(f.toString()); +		log.set_file(f); -		FileWriter w = new FileWriter(f); +		boolean do_write = true; -		eeprom.write(w); -		w.close(); +		if (f.exists()) +			do_write = monitor.check_overwrite(f); + +		if (do_write) { +			FileWriter w = new FileWriter(f); + +			eeprom.write(w); +			w.close(); +		} + +		if (eeprom.errors != 0) +			throw new ParseException(String.format("%d CRC Errors", eeprom.errors), 0); +	} + +	static String label(int flight) { +		if (flight < 0) +			return "Corrupt"; +		else +			return "Flight"; +	} + +	static int flight(int flight) { +		if (flight < 0) +			return -flight; +		return flight;  	}  	public void run () {  		boolean success = false;  		try { -			boolean	failed = false;  			if (remote)  				link.start_remote();  			for (AltosEepromLog log : flights) {  				parse_errors = null; -				if (log.selected) { +				if (log.download_selected) {  					monitor.reset();  					try {  						CaptureLog(log); @@ -226,16 +248,16 @@ public class AltosEepromDownload implements Runnable {  						LogError(e.getMessage());  					}  				} +				success = true;  				if (parse_errors != null) { -					failed = true; -					monitor.show_message(String.format("Flight %d download error. Valid log data saved\n%s", -									   log.flight, +					monitor.show_message(String.format("%s %d download error. Valid log data saved\n%s", +									   label(log.flight), +									   flight(log.flight),  									   parse_errors),  							     link.name,  							     AltosEepromMonitor.WARNING_MESSAGE);  				}  			} -			success = !failed;  		} catch (IOException ee) {  			monitor.show_message(ee.getLocalizedMessage(),  					     link.name,  | 
