altos: Rename telemetry to telemetry_orig
authorKeith Packard <keithp@keithp.com>
Wed, 22 Jun 2011 19:26:45 +0000 (12:26 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 28 Jun 2011 02:16:42 +0000 (19:16 -0700)
This makes room to create a new multi-packet telemetry format without
changing anything yet.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/Makefile.proto
src/ao.h
src/ao_monitor.c
src/ao_radio.c
src/ao_telemetrum.c
src/ao_telemetry.c [deleted file]
src/ao_telemetry_orig.c [new file with mode: 0644]

index c86de8236c096ef1bc00f605b7bdca3a812eb282..bc7b3a7f6cc54ce8aad55e7c007af73a044eebc0 100644 (file)
@@ -160,7 +160,7 @@ TM_TASK_SRC = \
        ao_log.c \
        ao_log_big.c \
        ao_report.c \
-       ao_telemetry.c
+       ao_telemetry_orig.c
 
 TM_MAIN_SRC = \
        ao_telemetrum.c
index 600c488a00f98aed631f5a717429690e162e4c57..b6a987e302f1bc1b2b13a70214dd1a35a284cfe1 100644 (file)
--- a/src/ao.h
+++ b/src/ao.h
@@ -1079,10 +1079,11 @@ struct ao_telemetry_tiny {
 /*
  * ao_radio_recv tacks on rssi and status bytes
  */
-struct ao_telemetry_recv {
-       struct ao_telemetry     telemetry;
-       int8_t                  rssi;
-       uint8_t                 status;
+
+struct ao_telemetry_orig_recv {
+       struct ao_telemetry_orig        telemetry_orig;
+       int8_t                          rssi;
+       uint8_t                         status;
 };
 
 struct ao_telemetry_tiny_recv {
@@ -1104,7 +1105,7 @@ void
 ao_rdf_set(uint8_t rdf);
 
 void
-ao_telemetry_init(void);
+ao_telemetry_orig_init(void);
 
 void
 ao_telemetry_tiny_init(void);
@@ -1160,7 +1161,7 @@ void
 ao_monitor(void);
 
 #define AO_MONITORING_OFF      0
-#define AO_MONITORING_FULL     1
+#define AO_MONITORING_ORIG     1
 #define AO_MONITORING_TINY     2
 
 void
index 8f2900716666ea71604433b619edc60e5821a748..248857debca265afbd35c127382e7fd20a896faf 100644 (file)
@@ -26,11 +26,12 @@ ao_monitor(void)
 {
        __xdata char callsign[AO_MAX_CALLSIGN+1];
        __xdata union {
-               struct ao_telemetry_recv        full;
+               struct ao_telemetry_orig_recv   orig;
                struct ao_telemetry_tiny_recv   tiny;
        } u;
 
-#define recv           (u.full)
+#define recv_raw       (u.raw)
+#define recv_orig      (u.orig)
 #define recv_tiny      (u.tiny)
 
        uint8_t state;
@@ -39,18 +40,19 @@ ao_monitor(void)
        for (;;) {
                __critical while (!ao_monitoring)
                        ao_sleep(&ao_monitoring);
-               if (ao_monitoring == AO_MONITORING_FULL) {
-                       if (!ao_radio_recv(&recv, sizeof (struct ao_telemetry_recv)))
+               switch (ao_monitoring) {
+               case AO_MONITORING_ORIG:
+                       if (!ao_radio_recv(&recv_orig, sizeof (struct ao_telemetry_orig_recv)))
                                continue;
 
-                       state = recv.telemetry.flight_state;
+                       state = recv_orig.telemetry_orig.flight_state;
 
                        /* Typical RSSI offset for 38.4kBaud at 433 MHz is 74 */
-                       rssi = (int16_t) (recv.rssi >> 1) - 74;
-                       memcpy(callsign, recv.telemetry.callsign, AO_MAX_CALLSIGN);
+                       rssi = (int16_t) (recv_orig.rssi >> 1) - 74;
+                       memcpy(callsign, recv_orig.telemetry_orig.callsign, AO_MAX_CALLSIGN);
                        if (state > ao_flight_invalid)
                                state = ao_flight_invalid;
-                       if (recv.status & PKT_APPEND_STATUS_1_CRC_OK) {
+                       if (recv_orig.status & PKT_APPEND_STATUS_1_CRC_OK) {
 
                                /* General header fields */
                                printf(AO_TELEM_VERSION " %d "
@@ -62,11 +64,11 @@ ao_monitor(void)
                                       AO_TELEM_TICK " %d ",
                                       AO_TELEMETRY_VERSION,
                                       callsign,
-                                      recv.telemetry.serial,
-                                      recv.telemetry.flight,
+                                      recv_orig.telemetry_orig.serial,
+                                      recv_orig.telemetry_orig.flight,
                                       rssi,
                                       ao_state_names[state],
-                                      recv.telemetry.adc.tick);
+                                      recv_orig.telemetry_orig.adc.tick);
 
                                /* Raw sensor values */
                                printf(AO_TELEM_RAW_ACCEL " %d "
@@ -75,48 +77,49 @@ ao_monitor(void)
                                       AO_TELEM_RAW_BATT " %d "
                                       AO_TELEM_RAW_DROGUE " %d "
                                       AO_TELEM_RAW_MAIN " %d ",
-                                      recv.telemetry.adc.accel,
-                                      recv.telemetry.adc.pres,
-                                      recv.telemetry.adc.temp,
-                                      recv.telemetry.adc.v_batt,
-                                      recv.telemetry.adc.sense_d,
-                                      recv.telemetry.adc.sense_m);
+                                      recv_orig.telemetry_orig.adc.accel,
+                                      recv_orig.telemetry_orig.adc.pres,
+                                      recv_orig.telemetry_orig.adc.temp,
+                                      recv_orig.telemetry_orig.adc.v_batt,
+                                      recv_orig.telemetry_orig.adc.sense_d,
+                                      recv_orig.telemetry_orig.adc.sense_m);
 
                                /* Sensor calibration values */
                                printf(AO_TELEM_CAL_ACCEL_GROUND " %d "
                                       AO_TELEM_CAL_BARO_GROUND " %d "
                                       AO_TELEM_CAL_ACCEL_PLUS " %d "
                                       AO_TELEM_CAL_ACCEL_MINUS " %d ",
-                                      recv.telemetry.ground_accel,
-                                      recv.telemetry.ground_pres,
-                                      recv.telemetry.accel_plus_g,
-                                      recv.telemetry.accel_minus_g);
+                                      recv_orig.telemetry_orig.ground_accel,
+                                      recv_orig.telemetry_orig.ground_pres,
+                                      recv_orig.telemetry_orig.accel_plus_g,
+                                      recv_orig.telemetry_orig.accel_minus_g);
 
-                               if (recv.telemetry.u.k.unused == 0x8000) {
+                               if (recv_orig.telemetry_orig.u.k.unused == 0x8000) {
                                        /* Kalman state values */
                                        printf(AO_TELEM_KALMAN_HEIGHT " %d "
                                               AO_TELEM_KALMAN_SPEED " %d "
                                               AO_TELEM_KALMAN_ACCEL " %d ",
-                                              recv.telemetry.height,
-                                              recv.telemetry.u.k.speed,
-                                              recv.telemetry.accel);
+                                              recv_orig.telemetry_orig.height,
+                                              recv_orig.telemetry_orig.u.k.speed,
+                                              recv_orig.telemetry_orig.accel);
                                } else {
                                        /* Ad-hoc flight values */
                                        printf(AO_TELEM_ADHOC_ACCEL " %d "
                                               AO_TELEM_ADHOC_SPEED " %ld "
                                               AO_TELEM_ADHOC_BARO " %d ",
-                                              recv.telemetry.accel,
-                                              recv.telemetry.u.flight_vel,
-                                              recv.telemetry.height);
+                                              recv_orig.telemetry_orig.accel,
+                                              recv_orig.telemetry_orig.u.flight_vel,
+                                              recv_orig.telemetry_orig.height);
                                }
-                               ao_gps_print(&recv.telemetry.gps);
-                               ao_gps_tracking_print(&recv.telemetry.gps_tracking);
+                               ao_gps_print(&recv_orig.telemetry_orig.gps);
+                               ao_gps_tracking_print(&recv_orig.telemetry_orig.gps_tracking);
                                putchar('\n');
                                ao_rssi_set(rssi);
                        } else {
                                printf("CRC INVALID RSSI %3d\n", rssi);
                        }
-               } else {
+                       break;
+               case AO_MONITORING_TINY:
                        if (!ao_radio_recv(&recv_tiny, sizeof (struct ao_telemetry_tiny_recv)))
                                continue;
 
@@ -181,6 +184,7 @@ ao_monitor(void)
                        } else {
                                printf("CRC INVALID RSSI %3d\n", rssi);
                        }
+                       break;
                }
                ao_usb_flush();
                ao_led_toggle(ao_monitor_led);
index b5a67b99d025d9801cb5b5a87a2ad61c72511ea6..01974ba1b3b61e73018dc37ae23bba9386e64c46 100644 (file)
@@ -161,8 +161,6 @@ static __code uint8_t radio_setup[] = {
        RF_SYNC0_OFF,           0x91,
 
        /* max packet length */
-       RF_PKTLEN_OFF,          sizeof (struct ao_telemetry),
-
        RF_PKTCTRL1_OFF,        ((1 << PKTCTRL1_PQT_SHIFT)|
                                 PKTCTRL1_APPEND_STATUS|
                                 PKTCTRL1_ADR_CHK_NONE),
@@ -233,7 +231,6 @@ static __code uint8_t fixed_pkt_setup[] = {
                                 (DEVIATION_M << RF_DEVIATN_DEVIATION_M_SHIFT)),
 
        /* max packet length -- now set inline */
-       // RF_PKTLEN_OFF,               sizeof (struct ao_telemetry),
        RF_PKTCTRL1_OFF,        ((1 << PKTCTRL1_PQT_SHIFT)|
                                 PKTCTRL1_APPEND_STATUS|
                                 PKTCTRL1_ADR_CHK_NONE),
index 4ace415c23be7b3487f6bc9768c7a3b8b47e7bdd..bede5868aa75083e4c81fed18fa247776e746e76 100644 (file)
@@ -57,7 +57,7 @@ main(void)
        ao_serial_init();
        ao_gps_init();
        ao_gps_report_init();
-       ao_telemetry_init();
+       ao_telemetry_orig_init();
        ao_radio_init();
        ao_packet_slave_init(TRUE);
        ao_igniter_init();
diff --git a/src/ao_telemetry.c b/src/ao_telemetry.c
deleted file mode 100644 (file)
index 9a86882..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright © 2009 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.
- */
-
-#include "ao.h"
-
-__xdata uint16_t ao_telemetry_interval = 0;
-__xdata uint8_t ao_rdf = 0;
-__xdata uint16_t ao_rdf_time;
-
-#define AO_RDF_INTERVAL_TICKS  AO_SEC_TO_TICKS(5)
-#define AO_RDF_LENGTH_MS       500
-
-void
-ao_telemetry(void)
-{
-       uint16_t        time;
-       int16_t         delay;
-       static __xdata struct ao_telemetry telemetry;
-
-       ao_config_get();
-       while (!ao_flight_number)
-               ao_sleep(&ao_flight_number);
-       memcpy(telemetry.callsign, ao_config.callsign, AO_MAX_CALLSIGN);
-       telemetry.serial = ao_serial_number;
-       telemetry.flight = ao_log_full() ? 0 : ao_flight_number;
-       telemetry.accel_plus_g = ao_config.accel_plus_g;
-       telemetry.accel_minus_g = ao_config.accel_minus_g;
-       for (;;) {
-               while (ao_telemetry_interval == 0)
-                       ao_sleep(&ao_telemetry_interval);
-               time = ao_rdf_time = ao_time();
-               while (ao_telemetry_interval) {
-                       telemetry.flight_state = ao_flight_state;
-                       telemetry.height = ao_height;
-                       telemetry.u.k.speed = ao_speed;
-                       telemetry.accel = ao_accel;
-                       telemetry.u.k.unused = 0x8000;
-#if HAS_ACCEL
-                       telemetry.ground_accel = ao_ground_accel;
-#endif
-                       telemetry.ground_pres = ao_ground_pres;
-#if HAS_ADC
-                       ao_adc_get(&telemetry.adc);
-#endif
-#if HAS_GPS
-                       ao_mutex_get(&ao_gps_mutex);
-                       memcpy(&telemetry.gps, &ao_gps_data, sizeof (struct ao_gps_data));
-                       memcpy(&telemetry.gps_tracking, &ao_gps_tracking_data, sizeof (struct ao_gps_tracking_data));
-                       ao_mutex_put(&ao_gps_mutex);
-#endif
-                       ao_radio_send(&telemetry, sizeof (telemetry));
-                       if (ao_rdf &&
-                           (int16_t) (ao_time() - ao_rdf_time) >= 0)
-                       {
-                               ao_rdf_time = ao_time() + AO_RDF_INTERVAL_TICKS;
-                               ao_radio_rdf(AO_RDF_LENGTH_MS);
-                       }
-                       time += ao_telemetry_interval;
-                       delay = time - ao_time();
-                       if (delay > 0)
-                               ao_delay(delay);
-                       else
-                               time = ao_time();
-               }
-       }
-}
-
-void
-ao_telemetry_set_interval(uint16_t interval)
-{
-       ao_telemetry_interval = interval;
-       ao_wakeup(&ao_telemetry_interval);
-}
-
-void
-ao_rdf_set(uint8_t rdf)
-{
-       ao_rdf = rdf;
-       if (rdf == 0)
-               ao_radio_rdf_abort();
-       else
-               ao_rdf_time = ao_time();
-}
-
-__xdata struct ao_task ao_telemetry_task;
-
-void
-ao_telemetry_init()
-{
-       ao_add_task(&ao_telemetry_task, ao_telemetry, "telemetry");
-}
diff --git a/src/ao_telemetry_orig.c b/src/ao_telemetry_orig.c
new file mode 100644 (file)
index 0000000..9a86882
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * Copyright © 2009 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.
+ */
+
+#include "ao.h"
+
+__xdata uint16_t ao_telemetry_interval = 0;
+__xdata uint8_t ao_rdf = 0;
+__xdata uint16_t ao_rdf_time;
+
+#define AO_RDF_INTERVAL_TICKS  AO_SEC_TO_TICKS(5)
+#define AO_RDF_LENGTH_MS       500
+
+void
+ao_telemetry(void)
+{
+       uint16_t        time;
+       int16_t         delay;
+       static __xdata struct ao_telemetry telemetry;
+
+       ao_config_get();
+       while (!ao_flight_number)
+               ao_sleep(&ao_flight_number);
+       memcpy(telemetry.callsign, ao_config.callsign, AO_MAX_CALLSIGN);
+       telemetry.serial = ao_serial_number;
+       telemetry.flight = ao_log_full() ? 0 : ao_flight_number;
+       telemetry.accel_plus_g = ao_config.accel_plus_g;
+       telemetry.accel_minus_g = ao_config.accel_minus_g;
+       for (;;) {
+               while (ao_telemetry_interval == 0)
+                       ao_sleep(&ao_telemetry_interval);
+               time = ao_rdf_time = ao_time();
+               while (ao_telemetry_interval) {
+                       telemetry.flight_state = ao_flight_state;
+                       telemetry.height = ao_height;
+                       telemetry.u.k.speed = ao_speed;
+                       telemetry.accel = ao_accel;
+                       telemetry.u.k.unused = 0x8000;
+#if HAS_ACCEL
+                       telemetry.ground_accel = ao_ground_accel;
+#endif
+                       telemetry.ground_pres = ao_ground_pres;
+#if HAS_ADC
+                       ao_adc_get(&telemetry.adc);
+#endif
+#if HAS_GPS
+                       ao_mutex_get(&ao_gps_mutex);
+                       memcpy(&telemetry.gps, &ao_gps_data, sizeof (struct ao_gps_data));
+                       memcpy(&telemetry.gps_tracking, &ao_gps_tracking_data, sizeof (struct ao_gps_tracking_data));
+                       ao_mutex_put(&ao_gps_mutex);
+#endif
+                       ao_radio_send(&telemetry, sizeof (telemetry));
+                       if (ao_rdf &&
+                           (int16_t) (ao_time() - ao_rdf_time) >= 0)
+                       {
+                               ao_rdf_time = ao_time() + AO_RDF_INTERVAL_TICKS;
+                               ao_radio_rdf(AO_RDF_LENGTH_MS);
+                       }
+                       time += ao_telemetry_interval;
+                       delay = time - ao_time();
+                       if (delay > 0)
+                               ao_delay(delay);
+                       else
+                               time = ao_time();
+               }
+       }
+}
+
+void
+ao_telemetry_set_interval(uint16_t interval)
+{
+       ao_telemetry_interval = interval;
+       ao_wakeup(&ao_telemetry_interval);
+}
+
+void
+ao_rdf_set(uint8_t rdf)
+{
+       ao_rdf = rdf;
+       if (rdf == 0)
+               ao_radio_rdf_abort();
+       else
+               ao_rdf_time = ao_time();
+}
+
+__xdata struct ao_task ao_telemetry_task;
+
+void
+ao_telemetry_init()
+{
+       ao_add_task(&ao_telemetry_task, ao_telemetry, "telemetry");
+}