altoslib: Extract a few more values from config to cal_data
authorKeith Packard <keithp@keithp.com>
Sun, 28 May 2017 20:58:05 +0000 (13:58 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 28 May 2017 20:58:05 +0000 (13:58 -0700)
Make it possible to display model/version data in the flight stats table.

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

index a9955ba8b503e52364cca89538c0641d164d03ff..960de30a45f5aeb1f3f89462c3697616559c43bc 100644 (file)
@@ -349,9 +349,16 @@ public class AltosCalData {
 
        public AltosCalData(AltosConfigData config_data) {
                set_serial(config_data.serial);
+               set_ticks_per_sec(100.0);
                set_flight(config_data.flight);
                set_callsign(config_data.callsign);
+               set_config(config_data.config_major, config_data.config_minor, config_data.flight_log_max);
+               set_firmware_version(config_data.version);
+               set_flight_params(config_data.apogee_delay / ticks_per_sec, config_data.apogee_lockout / ticks_per_sec);
+               set_pad_orientation(config_data.pad_orientation);
+               set_product(config_data.product);
                set_accel_plus_minus(config_data.accel_cal_plus, config_data.accel_cal_minus);
+               set_accel_zero(config_data.accel_zero_along, config_data.accel_zero_across, config_data.accel_zero_through);
                set_ms5607(config_data.ms5607);
                try {
                        set_mma655x_inverted(config_data.mma655x_inverted());
index 1972ca0f8cca87617d46069f369c725443b0e259..cb46b6c6349924e2db04109005a278eb9cd66b8d 100644 (file)
@@ -33,6 +33,7 @@ public class AltosConfigData {
        public int      log_space;
        public String   version;
        public int      altitude_32;
+       public int      config_major, config_minor;
 
        /* Config information */
        /* HAS_FLIGHT*/
@@ -236,6 +237,8 @@ public class AltosConfigData {
                log_format = AltosLib.AO_LOG_FORMAT_UNKNOWN;
                log_space = AltosLib.MISSING;
                version = "unknown";
+               config_major = AltosLib.MISSING;
+               config_minor = AltosLib.MISSING;
 
                main_deploy = AltosLib.MISSING;
                apogee_delay = AltosLib.MISSING;
@@ -283,6 +286,7 @@ public class AltosConfigData {
        }
 
        public void parse_line(String line) {
+
                /* Version replies */
                try { manufacturer = get_string(line, "manufacturer"); } catch (Exception e) {}
                try { product = get_string(line, "product"); } catch (Exception e) {}
@@ -306,6 +310,21 @@ public class AltosConfigData {
 
                /* Config show replies */
 
+               try {
+                       if (line.startsWith("Config version")) {
+                               String[] bits = line.split("\\s+");
+                               if (bits.length >= 3) {
+                                       String[] cfg = bits[2].split("\\.");
+
+                                       if (cfg.length >= 2) {
+                                               System.out.printf("major %s minor %s\n", cfg[0], cfg[1]);
+                                               config_major = Integer.parseInt(cfg[0]);
+                                               config_minor = Integer.parseInt(cfg[1]);
+                                       }
+                               }
+                       }
+               } catch (Exception e) {}
+
                /* HAS_FLIGHT */
                try { main_deploy = get_int(line, "Main deploy:"); } catch (Exception e) {}
                try { apogee_delay = get_int(line, "Apogee delay:"); } catch (Exception e) {}