altoslib: Make sure AltosFlightSeries is filled in before use
[fw/altos] / altoslib / AltosIdleReader.java
index 795593f7750575cea02ce3312d885679236fe152..49d0cf61cd3f73338e3049a4ab4b7b8c11f937e8 100644 (file)
@@ -3,7 +3,8 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -47,11 +48,6 @@ public class AltosIdleReader extends AltosFlightReader {
                boolean worked = false;
                boolean aborted = false;
 
-               if (state == null)
-                       state = new AltosState();
-               else
-                       state = state.clone();
-
                long    delay = next_millis - System.currentTimeMillis();
 
                if (delay > 0)
@@ -60,7 +56,9 @@ public class AltosIdleReader extends AltosFlightReader {
                try {
                        try {
                                start_link();
-                               fetch.update_state(state);
+                               if (state == null)
+                                       state = new AltosState(new AltosCalData(link.config_data()));
+                               fetch.provide_data(state, state.cal_data);
                                if (!link.has_error && !link.reply_abort)
                                        worked = true;
                        } catch (TimeoutException te) {