From b10fbbf0830053a39e4640a53598b1c027615c63 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 1 Aug 2011 22:44:13 -0700 Subject: [PATCH] altos: Add 'send all baro' compile-time option This option creates a new packet type that delivers full sensor-rate barometer telemetry data to allow for off-line analysis of flight algorithms using all of the data, rather than the slower rate provided either over telemetry or stored in the eeprom file. Define AO_SEND_ALL_BARO and this will get built in. Perhaps this could be a run-time option... Signed-off-by: Keith Packard --- src/core/ao.h | 31 +++++++++++++++++++++++++++++++ src/core/ao_telemetry.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/src/core/ao.h b/src/core/ao.h index c926c001..0cff0436 100644 --- a/src/core/ao.h +++ b/src/core/ao.h @@ -1118,6 +1118,30 @@ struct ao_telemetry_companion { /* 32 */ }; +/* #define AO_SEND_ALL_BARO */ + +#define AO_TELEMETRY_BARO 0x80 + +/* + * This packet allows the full sampling rate baro + * data to be captured over the RF link so that the + * flight software can be tested using 'real' data. + * + * Along with this telemetry packet, the flight + * code is modified to send full-rate telemetry all the time + * and never send an RDF tone; this ensure that the full radio + * link is available. + */ +struct ao_telemetry_baro { + uint16_t serial; /* 0 */ + uint16_t tick; /* 2 */ + uint8_t type; /* 4 */ + uint8_t samples; /* 5 number samples */ + + int16_t baro[12]; /* 6 samples */ + /* 32 */ +}; + union ao_telemetry_all { struct ao_telemetry_generic generic; struct ao_telemetry_sensor sensor; @@ -1125,6 +1149,7 @@ union ao_telemetry_all { struct ao_telemetry_location location; struct ao_telemetry_satellite satellite; struct ao_telemetry_companion companion; + struct ao_telemetry_baro baro; }; /* @@ -1258,9 +1283,15 @@ struct ao_telemetry_raw_recv { /* Set delay between telemetry reports (0 to disable) */ +#ifdef AO_SEND_ALL_BARO +#define AO_TELEMETRY_INTERVAL_PAD AO_MS_TO_TICKS(100) +#define AO_TELEMETRY_INTERVAL_FLIGHT AO_MS_TO_TICKS(100) +#define AO_TELEMETRY_INTERVAL_RECOVER AO_MS_TO_TICKS(100) +#else #define AO_TELEMETRY_INTERVAL_PAD AO_MS_TO_TICKS(1000) #define AO_TELEMETRY_INTERVAL_FLIGHT AO_MS_TO_TICKS(100) #define AO_TELEMETRY_INTERVAL_RECOVER AO_MS_TO_TICKS(1000) +#endif void ao_telemetry_set_interval(uint16_t interval); diff --git a/src/core/ao_telemetry.c b/src/core/ao_telemetry.c index c7338a58..de669ce1 100644 --- a/src/core/ao_telemetry.c +++ b/src/core/ao_telemetry.c @@ -94,6 +94,30 @@ ao_send_sensor(void) ao_radio_send(&telemetry, sizeof (telemetry)); } +static uint8_t ao_baro_sample; + +#ifdef AO_SEND_ALL_BARO +static void +ao_send_baro(void) +{ + uint8_t sample = ao_sample_adc; + uint8_t samples = (sample - ao_baro_sample) & (AO_ADC_RING - 1); + + if (samples > 12) { + ao_baro_sample = (ao_baro_sample + (samples - 12)) & (AO_ADC_RING - 1); + samples = 12; + } + telemetry.generic.tick = ao_adc_ring[sample].tick; + telemetry.generic.type = AO_TELEMETRY_BARO; + telemetry.baro.samples = samples; + for (sample = 0; sample < samples; sample++) { + telemetry.baro.baro[sample] = ao_adc_ring[ao_baro_sample].pres; + ao_baro_sample = ao_adc_ring_next(ao_baro_sample); + } + ao_radio_send(&telemetry, sizeof (telemetry)); +} +#endif + static void ao_send_configuration(void) { @@ -193,6 +217,9 @@ ao_telemetry(void) while (ao_telemetry_interval) { +#ifdef AO_SEND_ALL_BARO + ao_send_baro(); +#endif ao_send_sensor(); #if HAS_COMPANION if (ao_companion_running) @@ -203,12 +230,14 @@ ao_telemetry(void) ao_send_location(); ao_send_satellite(); #endif +#ifndef AO_SEND_ALL_BARO 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); } +#endif time += ao_telemetry_interval; delay = time - ao_time(); if (delay > 0) -- 2.30.2