altoslib: Fetch target device config for Fire Igniter npyro value
authorKeith Packard <keithp@keithp.com>
Wed, 22 Jan 2014 05:34:58 +0000 (21:34 -0800)
committerKeith Packard <keithp@keithp.com>
Wed, 22 Jan 2014 05:34:58 +0000 (21:34 -0800)
The code was using the AltosLink config_data, which is always the
locally connected device's configuration. When using the packet link,
that's not terribly useful when asking how many extra pyro channels
are available.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosIgnite.java

index d3c21796690fec5585f8460e9f9e20d30dff8554..8ab47d1de49a9ba8c54e6327ca096addd5334563 100644 (file)
@@ -27,6 +27,7 @@ public class AltosIgnite {
        boolean         link_started;
        boolean         have_npyro = false;
        int             npyro;
+       AltosConfigData config_data;
 
        public final static String      None = null;
        public final static String      Apogee = "drogue";
@@ -97,8 +98,12 @@ public class AltosIgnite {
        }
 
        private void get_npyro() throws InterruptedException, TimeoutException {
-               AltosConfigData config_data = link.config_data();
-               npyro = config_data.npyro;
+               if (config_data == null)
+                       config_data = new AltosConfigData(link);
+               if (config_data != null)
+                       npyro = config_data.npyro;
+               else
+                       npyro = 0;
                have_npyro = true;
        }