altoslib: Store MS5607 data in AltosConfigData for use by AltosMs5607
authorKeith Packard <keithp@keithp.com>
Fri, 6 Feb 2015 12:45:17 +0000 (04:45 -0800)
committerKeith Packard <keithp@keithp.com>
Fri, 6 Feb 2015 12:45:17 +0000 (04:45 -0800)
When doing 'Monitor Idle', we fetch new config data each iteration and
pass that to each of the readers, including ms5607. Instead of
re-fetching the config data there, just store the ms5607 parameters
when we fetch it the first time and copy it over.

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

index a9e863c7759edac882571fa00ab7904d190b7602..65f6346a4c00633ce6aede342c2fad71da08560d 100644 (file)
@@ -93,6 +93,16 @@ public class AltosConfigData implements Iterable<String> {
        /* HAS_GYRO */
        public int      accel_zero_along, accel_zero_across, accel_zero_through;
 
+       /* ms5607 data */
+       public int      ms5607_reserved;
+       public int      ms5607_sens;
+       public int      ms5607_off;
+       public int      ms5607_tcs;
+       public int      ms5607_tco;
+       public int      ms5607_tref;
+       public int      ms5607_tempsens;
+       public int      ms5607_crc;
+
        public static String get_string(String line, String label) throws  ParseException {
                if (line.startsWith(label)) {
                        String  quoted = line.substring(label.length()).trim();
@@ -289,6 +299,15 @@ public class AltosConfigData implements Iterable<String> {
 
                /* Version also contains MS5607 info, which we ignore here */
 
+               try { ms5607_reserved = get_int(line, "ms5607 reserved:"); } catch (Exception e) {}
+               try { ms5607_sens = get_int(line, "ms5607 sens:"); } catch (Exception e) {}
+               try { ms5607_off = get_int(line, "ms5607 off:"); } catch (Exception e) {}
+               try { ms5607_tcs = get_int(line, "ms5607 tcs:"); } catch (Exception e) {}
+               try { ms5607_tco = get_int(line, "ms5607 tco:"); } catch (Exception e) {}
+               try { ms5607_tref = get_int(line, "ms5607 tref:"); } catch (Exception e) {}
+               try { ms5607_tempsens = get_int(line, "ms5607 tempsens:"); } catch (Exception e) {}
+               try { ms5607_crc = get_int(line, "ms5607 crc:"); } catch (Exception e) {}
+
                /* Config show replies */
 
                /* HAS_FLIGHT */
index 50745d9755d9be1436932d62c848615bdb51f255..981035d4978b093a6dfb4dab787a9ddccd92eee4 100644 (file)
@@ -131,6 +131,7 @@ public class AltosIdleFetch implements AltosStateUpdate {
 
        public void update_state(AltosState state) throws InterruptedException {
                try {
+                       /* Fetch config data from remote */
                        AltosConfigData config_data = new AltosConfigData(link);
                        state.set_state(AltosLib.ao_flight_startup);
                        state.set_serial(config_data.serial);
index 97e17164bd03482c491a6ddd9cde62eb94ebe04e..056a8490cc3f253a856ec2bb0281615663cc7c35 100644 (file)
@@ -127,7 +127,7 @@ public class AltosMs5607 implements Serializable {
 
        static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException {
                try {
-                       AltosMs5607     ms5607 = new AltosMs5607(link);
+                       AltosMs5607     ms5607 = new AltosMs5607(link, config_data);
 
                        if (ms5607 != null) {
                                state.set_ms5607(ms5607);
@@ -144,9 +144,17 @@ public class AltosMs5607 implements Serializable {
                cc = AltosLib.MISSING;
        }
 
-       public AltosMs5607 (AltosLink link) throws InterruptedException, TimeoutException {
+       public AltosMs5607 (AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException {
                this();
-               link.printf("c s\nB\n");
+               reserved = config_data.ms5607_reserved;
+               sens = config_data.ms5607_sens;
+               off = config_data.ms5607_off;
+               tcs = config_data.ms5607_tcs;
+               tco = config_data.ms5607_tco;
+               tref = config_data.ms5607_tref;
+               tempsens = config_data.ms5607_tempsens;
+               crc = config_data.ms5607_crc;
+               link.printf("B\n");
                for (;;) {
                        String line = link.get_reply_no_dialog(5000);
                        if (line == null) {