Add TeleMini v2.0 telemetry support
authorKeith Packard <keithp@keithp.com>
Thu, 19 Sep 2013 05:28:55 +0000 (00:28 -0500)
committerKeith Packard <keithp@keithp.com>
Thu, 19 Sep 2013 05:28:55 +0000 (00:28 -0500)
Includes AltosLib and ao-telem

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosIdleFetch.java
altoslib/AltosSensorTMini.java [new file with mode: 0644]
altoslib/AltosTelemetryMini.java [new file with mode: 0644]
altoslib/AltosTelemetryStandard.java
altoslib/Makefile.am
ao-tools/ao-telem/ao-telem.c

index 42943c07c478e7cfb4f1ae426ef8f254d7e0c5a2..64c421f4f3e5db5858a9f921eaa98446ff67d08d 100644 (file)
@@ -37,6 +37,7 @@ class AltosIdler {
        static final int        idle_sensor_metrum = 11;
        static final int        idle_sensor_mega = 12;
        static final int        idle_sensor_emini = 13;
        static final int        idle_sensor_metrum = 11;
        static final int        idle_sensor_mega = 12;
        static final int        idle_sensor_emini = 13;
+       static final int        idle_sensor_tmini = 14;
 
        public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException {
                for (int idler : idlers) {
 
        public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException {
                for (int idler : idlers) {
@@ -69,6 +70,8 @@ class AltosIdler {
                        case idle_sensor_emini:
                                AltosSensorEMini.update_state(state, link, config_data);
                                break;
                        case idle_sensor_emini:
                                AltosSensorEMini.update_state(state, link, config_data);
                                break;
+                       case idle_sensor_tmini:
+                               AltosSensorTMini.update_state(state, link, config_data);
                        }
                        if (idle != null)
                                idle.update_state(state);
                        }
                        if (idle != null)
                                idle.update_state(state);
@@ -99,7 +102,7 @@ public class AltosIdleFetch implements AltosStateUpdate {
 
                new AltosIdler("TeleMini-v2",
                               AltosIdler.idle_ms5607,
 
                new AltosIdler("TeleMini-v2",
                               AltosIdler.idle_ms5607,
-                              AltosIdler.idle_sensor_tm),
+                              AltosIdler.idle_sensor_tmini),
 
                new AltosIdler("TeleMetrum-v1",
                               AltosIdler.idle_gps,
 
                new AltosIdler("TeleMetrum-v1",
                               AltosIdler.idle_gps,
diff --git a/altoslib/AltosSensorTMini.java b/altoslib/AltosSensorTMini.java
new file mode 100644 (file)
index 0000000..be071e5
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright © 2012 Keith Packard <keithp@keithp.com>
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.altoslib_2;
+
+import java.util.concurrent.TimeoutException;
+
+public class AltosSensorTMini {
+       public int      tick;
+       public int      apogee;
+       public int      main;
+       public int      batt;
+
+       static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) {
+               try {
+                       AltosSensorTMini        sensor_tmini = new AltosSensorTMini(link);
+
+                       if (sensor_tmini == null)
+                               return;
+                       state.set_battery_voltage(AltosConvert.easy_mini_voltage(sensor_tmini.batt));
+                       state.set_apogee_voltage(AltosConvert.easy_mini_voltage(sensor_tmini.apogee));
+                       state.set_main_voltage(AltosConvert.easy_mini_voltage(sensor_tmini.main));
+                       
+               } catch (TimeoutException te) {
+               } catch (InterruptedException ie) {
+               }
+       }
+
+       public AltosSensorTMini(AltosLink link) throws InterruptedException, TimeoutException {
+               String[] items = link.adc();
+               for (int i = 0; i < items.length;) {
+                       if (items[i].equals("tick:")) {
+                               tick = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
+                       }
+                       if (items[i].equals("apogee:")) {
+                               apogee = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
+                       }
+                       if (items[i].equals("main:")) {
+                               main = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
+                       }
+                       if (items[i].equals("batt:")) {
+                               batt = Integer.parseInt(items[i+1]);
+                               i += 2;
+                               continue;
+                       }
+                       i++;
+               }
+       }
+}
+
diff --git a/altoslib/AltosTelemetryMini.java b/altoslib/AltosTelemetryMini.java
new file mode 100644 (file)
index 0000000..e710946
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright © 2011 Keith Packard <keithp@keithp.com>
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.altoslib_2;
+
+
+public class AltosTelemetryMini extends AltosTelemetryStandard {
+       int     state;
+
+       int     v_batt;
+       int     sense_a;
+       int     sense_m;
+
+       int     pres;
+       int     temp;
+
+       int     acceleration;
+       int     speed;
+       int     height;
+
+       int     ground_pres;
+
+       public AltosTelemetryMini(int[] bytes) {
+               super(bytes);
+
+               state         = int8(5);
+
+               v_batt        = int16(6);
+               sense_a       = int16(8);
+               sense_m       = int16(10);
+
+               pres          = int32(12);
+               temp          = int16(16);
+
+               acceleration  = int16(18);
+               speed         = int16(20);
+               height        = int16(22);
+
+               ground_pres   = int32(24);
+       }
+
+       public void update_state(AltosState state) {
+               super.update_state(state);
+
+               state.set_state(this.state);
+
+               state.set_battery_voltage(AltosConvert.tele_mini_voltage(v_batt));
+               state.set_apogee_voltage(AltosConvert.tele_mini_voltage(sense_a));
+               state.set_main_voltage(AltosConvert.tele_mini_voltage(sense_m));
+
+               state.set_ground_pressure(ground_pres);
+
+               state.set_pressure(pres);
+               state.set_temperature(temp/100.0);
+
+               state.set_kalman(height, speed/16.0, acceleration/16.0);
+       }
+}
index fbcc970c0e11504485195378b235dfe130ca72d2..3186ae097c8460737156bbb3b516a739f76bc18a 100644 (file)
@@ -85,6 +85,9 @@ public abstract class AltosTelemetryStandard extends AltosTelemetry {
                case packet_type_metrum_data:
                        telem = new AltosTelemetryMetrumData(bytes);
                        break;
                case packet_type_metrum_data:
                        telem = new AltosTelemetryMetrumData(bytes);
                        break;
+               case packet_type_mini:
+                       telem = new AltosTelemetryMini(bytes);
+                       break;
                default:
                        telem = new AltosTelemetryRaw(bytes);
                        break;
                default:
                        telem = new AltosTelemetryRaw(bytes);
                        break;
index 2c78ae7238eae3d753f7361f3ec6369ca00e5518..c1cf053cc257aaaa0ddafef3ecb86e06f61a368c 100644 (file)
@@ -73,6 +73,7 @@ altoslib_JAVA = \
        AltosSensorMM.java \
        AltosSensorEMini.java \
        AltosSensorTM.java \
        AltosSensorMM.java \
        AltosSensorEMini.java \
        AltosSensorTM.java \
+       AltosSensorTMini.java \
        AltosSensorMega.java \
        AltosSensorMetrum.java \
        AltosState.java \
        AltosSensorMega.java \
        AltosSensorMetrum.java \
        AltosState.java \
@@ -87,6 +88,7 @@ altoslib_JAVA = \
        AltosTelemetryMap.java \
        AltosTelemetryMegaSensor.java \
        AltosTelemetryMegaData.java \
        AltosTelemetryMap.java \
        AltosTelemetryMegaSensor.java \
        AltosTelemetryMegaData.java \
+       AltosTelemetryMini.java \
        AltosTelemetryMetrumSensor.java \
        AltosTelemetryMetrumData.java \
        AltosTelemetryReader.java \
        AltosTelemetryMetrumSensor.java \
        AltosTelemetryMetrumData.java \
        AltosTelemetryReader.java \
index 893e2340342bb3b2cfa7781fee121c83f58d63a1..f1755b824f82ef233a89d6ec9312bdea623700c9 100644 (file)
@@ -214,6 +214,19 @@ main (int argc, char **argv)
                                                telem.metrum_data.accel_plus_g,
                                                telem.metrum_data.accel_minus_g);
                                        break;
                                                telem.metrum_data.accel_plus_g,
                                                telem.metrum_data.accel_minus_g);
                                        break;
+                               case AO_TELEMETRY_MINI:
+                                       printf ("state %1d v_batt %5d sense_a %5d sense_m %5d pres %9d temp %6.2f acceleration %6.2f speed %6.2f height %5d ground_pres %9d\n",
+                                               telem.mini.state,
+                                               telem.mini.v_batt,
+                                               telem.mini.sense_a,
+                                               telem.mini.sense_m,
+                                               telem.mini.pres,
+                                               telem.mini.temp / 100.0,
+                                               telem.mini.acceleration / 16.0,
+                                               telem.mini.speed / 16.0,
+                                               telem.mini.height,
+                                               telem.mini.ground_pres);
+                                       break;
                                default:
                                        printf("\n");
                                }
                                default:
                                        printf("\n");
                                }