diff options
| author | Keith Packard <keithp@keithp.com> | 2009-04-20 23:33:41 -0700 |
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2009-04-20 23:33:41 -0700 |
| commit | 43c8f7012102cdb591ace899420c10e4a78385ad (patch) | |
| tree | 6ce45d0a58b1133961acd3cda3f3be21fef085b4 /ao_monitor.c | |
| parent | 5be13b76a2e29b84cd6d1eec065e3354b0dafce5 (diff) | |
Add radio support. Build separate executables for TeleMetrum and the TI dongle
Ok, way too big a patch, but things were in rough shape.
This patch adds support for the radio, both transmit and receive.
Then, because I could no longer run the TeleMetrum code on the TI
dongle, I ended up building a separate image for the TI board, which
involved creating a mechanism for having multiple command sets and splitting
code for different functions into different files.
Diffstat (limited to 'ao_monitor.c')
| -rw-r--r-- | ao_monitor.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/ao_monitor.c b/ao_monitor.c new file mode 100644 index 00000000..1c2d1274 --- /dev/null +++ b/ao_monitor.c @@ -0,0 +1,73 @@ +/* + * $Id: $ + * + * Copyright © 2009 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "ao.h" + +const char const * const ao_state_names[] = { + "startup", "idle", "pad", "boost", "coast", + "apogee", "drogue", "main", "landed", "invalid" +}; + +void +ao_monitor(void) +{ + __xdata struct ao_radio_recv recv; + uint8_t state; + + for (;;) { + ao_radio_recv(&recv); + state = recv.telemetry.flight_state; + if (state > ao_flight_invalid) + state = ao_flight_invalid; + printf ("SERIAL %3d RSSI %3d STATUS %02x STATE %s ", + recv.telemetry.addr, recv.rssi, recv.status, + ao_state_names[state]); + if (!(recv.status & PKT_APPEND_STATUS_1_CRC_OK)) + printf("CRC INVALID "); + switch (recv.telemetry.type) { + case AO_TELEMETRY_SENSOR: + printf("%5u a: %d p: %d t: %d v: %d d: %d m: %d\n", + recv.telemetry.u.adc.tick, + recv.telemetry.u.adc.accel, + recv.telemetry.u.adc.pres, + recv.telemetry.u.adc.temp, + recv.telemetry.u.adc.v_batt, + recv.telemetry.u.adc.sense_d, + recv.telemetry.u.adc.sense_m); + break; + case AO_TELEMETRY_GPS: + ao_gps_print(&recv.telemetry.u.gps); + break; + } + ao_usb_flush(); + } +} + +__xdata struct ao_task ao_monitor_task; + +void +ao_monitor_init(void) +{ + ao_add_task(&ao_monitor_task, ao_monitor, "monitor"); +} |
