diff options
| author | Keith Packard <keithp@keithp.com> | 2017-05-27 23:33:07 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2017-05-27 23:33:07 -0700 | 
| commit | c87ba4b243a9fd838a3c97cc6a95cceb450a6ba5 (patch) | |
| tree | 60248dc6bd79c6370a27ea721c0d0d3241e6e720 | |
| parent | c9e82a5929a836bc61b464507badef2df5e9d4d0 (diff) | |
altoslib: Provide consistent cal_data from idle and replay readers
Signed-off-by: Keith Packard <keithp@keithp.com>
| -rw-r--r-- | altoslib/AltosIdleReader.java | 16 | ||||
| -rw-r--r-- | altoslib/AltosReplayReader.java | 4 | 
2 files changed, 19 insertions, 1 deletions
diff --git a/altoslib/AltosIdleReader.java b/altoslib/AltosIdleReader.java index 49d0cf61..3307cf26 100644 --- a/altoslib/AltosIdleReader.java +++ b/altoslib/AltosIdleReader.java @@ -25,6 +25,7 @@ import java.util.concurrent.*;  public class AltosIdleReader extends AltosFlightReader {  	AltosLink	link;  	boolean		remote; +	AltosCalData	cal_data = null;  	AltosState	state = null;  	AltosIdleFetch	fetch;  	long		next_millis; @@ -44,6 +45,19 @@ public class AltosIdleReader extends AltosFlightReader {  		return link.reply_abort;  	} +	public AltosCalData cal_data() { +		if (cal_data == null) { +			try { +				cal_data = new AltosCalData(link.config_data()); +			} catch (InterruptedException ie) { +			} catch (TimeoutException te) { +			} +			if (cal_data == null) +				cal_data = new AltosCalData(); +		} +		return cal_data; +	} +  	public AltosState read() throws InterruptedException, ParseException, AltosCRCException, IOException {  		boolean worked = false;  		boolean aborted = false; @@ -57,7 +71,7 @@ public class AltosIdleReader extends AltosFlightReader {  			try {  				start_link();  				if (state == null) -					state = new AltosState(new AltosCalData(link.config_data())); +					state = new AltosState(cal_data());  				fetch.provide_data(state, state.cal_data);  				if (!link.has_error && !link.reply_abort)  					worked = true; diff --git a/altoslib/AltosReplayReader.java b/altoslib/AltosReplayReader.java index 2117bc87..a26d1e84 100644 --- a/altoslib/AltosReplayReader.java +++ b/altoslib/AltosReplayReader.java @@ -107,6 +107,10 @@ public class AltosReplayReader extends AltosFlightReader {  	Thread		t;  	int		reads; +	public AltosCalData cal_data() { +		return replay.state.cal_data; +	} +  	public AltosState read() {  		switch (reads) {  		case 0:  | 
