X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altoslib%2FAltosIdleReader.java;h=3307cf2646a47587f20fbe24886129c46732bdf5;hb=4c5acb57d7ac1abec7bb4cda9dc88c2a19767a2d;hp=49d0cf61cd3f73338e3049a4ab4b7b8c11f937e8;hpb=f26cfe417c6977cf1e7e75a4f050e25f64d41859;p=fw%2Faltos 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;