2 * Copyright © 2009 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20 __xdata uint8_t ao_monitoring;
21 __pdata uint8_t ao_monitor_led;
26 __xdata struct ao_radio_recv recv;
27 __xdata char callsign[AO_MAX_CALLSIGN+1];
31 __critical while (!ao_monitoring)
32 ao_sleep(&ao_monitoring);
33 if (!ao_radio_recv(&recv))
35 state = recv.telemetry.flight_state;
36 memcpy(callsign, recv.telemetry.callsign, AO_MAX_CALLSIGN);
37 if (state > ao_flight_invalid)
38 state = ao_flight_invalid;
39 if (recv.status & PKT_APPEND_STATUS_1_CRC_OK) {
40 printf("VERSION %d CALL %s SERIAL %3d FLIGHT %5u RSSI %4d STATUS %02x STATE %7s ",
44 recv.telemetry.flight,
45 (int) recv.rssi - 74, recv.status,
46 ao_state_names[state]);
47 printf("%5u a: %5d p: %5d t: %5d v: %5d d: %5d m: %5d "
48 "fa: %5d ga: %d fv: %7ld fp: %5d gp: %5d a+: %5d a-: %5d ",
49 recv.telemetry.adc.tick,
50 recv.telemetry.adc.accel,
51 recv.telemetry.adc.pres,
52 recv.telemetry.adc.temp,
53 recv.telemetry.adc.v_batt,
54 recv.telemetry.adc.sense_d,
55 recv.telemetry.adc.sense_m,
56 recv.telemetry.flight_accel,
57 recv.telemetry.ground_accel,
58 recv.telemetry.flight_vel,
59 recv.telemetry.flight_pres,
60 recv.telemetry.ground_pres,
61 recv.telemetry.accel_plus_g,
62 recv.telemetry.accel_minus_g);
63 ao_gps_print(&recv.telemetry.gps);
65 ao_gps_tracking_print(&recv.telemetry.gps_tracking);
67 ao_rssi_set((int) recv.rssi - 74);
69 printf("CRC INVALID RSSI %3d\n", (int) recv.rssi - 74);
72 ao_led_toggle(ao_monitor_led);
76 __xdata struct ao_task ao_monitor_task;
79 ao_set_monitor(uint8_t monitoring)
81 ao_monitoring = monitoring;
82 ao_wakeup(&ao_monitoring);
91 ao_set_monitor(ao_cmd_lex_i != 0);
94 __code struct ao_cmds ao_monitor_cmds[] = {
95 { 'm', set_monitor, "m <0 off, 1 on> Enable/disable radio monitoring" },
96 { 0, set_monitor, NULL },
100 ao_monitor_init(uint8_t monitor_led, uint8_t monitoring) __reentrant
102 ao_monitor_led = monitor_led;
103 ao_monitoring = monitoring;
104 ao_cmd_register(&ao_monitor_cmds[0]);
105 ao_add_task(&ao_monitor_task, ao_monitor, "monitor");