altos: Add arbitrary telemetry packet monitoring
authorKeith Packard <keithp@keithp.com>
Wed, 22 Jun 2011 19:27:34 +0000 (12:27 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 28 Jun 2011 02:16:42 +0000 (19:16 -0700)
This adds the ability to monitor arbitrary telemetry packets (up to
128 bytes), moving the telemetry data parsing up to the host.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/ao.h
src/ao_monitor.c
src/ao_telemetry_orig.c

index b6a987e302f1bc1b2b13a70214dd1a35a284cfe1..f57537033caf029d89eec35dfb281569ae4de5aa 100644 (file)
--- a/src/ao.h
+++ b/src/ao.h
@@ -1036,12 +1036,13 @@ void
 ao_gps_report_init(void);
 
 /*
 ao_gps_report_init(void);
 
 /*
- * ao_telemetry.c
+ * ao_telemetry_orig.c
  */
 
 #define AO_MAX_CALLSIGN                        8
  */
 
 #define AO_MAX_CALLSIGN                        8
+#define AO_MAX_TELEMETRY               128
 
 
-struct ao_telemetry {
+struct ao_telemetry_orig {
        uint16_t                serial;
        uint16_t                flight;
        uint8_t                 flight_state;
        uint16_t                serial;
        uint16_t                flight;
        uint8_t                 flight_state;
@@ -1080,6 +1081,10 @@ struct ao_telemetry_tiny {
  * ao_radio_recv tacks on rssi and status bytes
  */
 
  * ao_radio_recv tacks on rssi and status bytes
  */
 
+struct ao_telemetry_raw_recv {
+       uint8_t                 packet[AO_MAX_TELEMETRY + 2];
+};
+
 struct ao_telemetry_orig_recv {
        struct ao_telemetry_orig        telemetry_orig;
        int8_t                          rssi;
 struct ao_telemetry_orig_recv {
        struct ao_telemetry_orig        telemetry_orig;
        int8_t                          rssi;
index 248857debca265afbd35c127382e7fd20a896faf..ac1929db1aea5ee2563ff5bb295fe53868970069 100644 (file)
@@ -26,6 +26,7 @@ ao_monitor(void)
 {
        __xdata char callsign[AO_MAX_CALLSIGN+1];
        __xdata union {
 {
        __xdata char callsign[AO_MAX_CALLSIGN+1];
        __xdata union {
+               struct ao_telemetry_raw_recv    raw;
                struct ao_telemetry_orig_recv   orig;
                struct ao_telemetry_tiny_recv   tiny;
        } u;
                struct ao_telemetry_orig_recv   orig;
                struct ao_telemetry_tiny_recv   tiny;
        } u;
@@ -185,6 +186,15 @@ ao_monitor(void)
                                printf("CRC INVALID RSSI %3d\n", rssi);
                        }
                        break;
                                printf("CRC INVALID RSSI %3d\n", rssi);
                        }
                        break;
+               default:
+                       if (ao_monitoring > AO_MAX_TELEMETRY)
+                               ao_monitoring = AO_MAX_TELEMETRY;
+                       if (!ao_radio_recv(&recv_raw, ao_monitoring))
+                               continue;
+                       for (state = 0; state < ao_monitoring + 1; state++)
+                               printf("%02x ", recv_raw.packet[state]);
+                       printf("%02x\n", recv_raw.packet[state]);
+                       break;
                }
                ao_usb_flush();
                ao_led_toggle(ao_monitor_led);
                }
                ao_usb_flush();
                ao_led_toggle(ao_monitor_led);
index 9a86882f45f9ff5b63fcfd224ea137f1eb860d59..4b3a344a3cc80dbc960e684c8109ace2f09fdfd0 100644 (file)
@@ -25,11 +25,11 @@ __xdata uint16_t ao_rdf_time;
 #define AO_RDF_LENGTH_MS       500
 
 void
 #define AO_RDF_LENGTH_MS       500
 
 void
-ao_telemetry(void)
+ao_telemetry_orig(void)
 {
        uint16_t        time;
        int16_t         delay;
 {
        uint16_t        time;
        int16_t         delay;
-       static __xdata struct ao_telemetry telemetry;
+       static __xdata struct ao_telemetry_orig telemetry;
 
        ao_config_get();
        while (!ao_flight_number)
 
        ao_config_get();
        while (!ao_flight_number)
@@ -96,10 +96,10 @@ ao_rdf_set(uint8_t rdf)
                ao_rdf_time = ao_time();
 }
 
                ao_rdf_time = ao_time();
 }
 
-__xdata struct ao_task ao_telemetry_task;
+__xdata struct ao_task ao_telemetry_orig_task;
 
 void
 
 void
-ao_telemetry_init()
+ao_telemetry_orig_init()
 {
 {
-       ao_add_task(&ao_telemetry_task, ao_telemetry, "telemetry");
+       ao_add_task(&ao_telemetry_orig_task, ao_telemetry_orig, "telemetry_orig");
 }
 }