2 * Copyright © 2012 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.
18 #ifndef _AO_TELEMETRY_H_
19 #define _AO_TELEMETRY_H_
24 #define AO_MAX_CALLSIGN 8
25 #define AO_MAX_VERSION 8
27 #define AO_MAX_TELEMETRY 128
29 #define AO_MAX_TELEMETRY 32
32 struct ao_telemetry_generic {
33 uint16_t serial; /* 0 */
34 uint16_t tick; /* 2 */
36 uint8_t payload[27]; /* 5 */
40 #define AO_TELEMETRY_SENSOR_TELEMETRUM 0x01
41 #define AO_TELEMETRY_SENSOR_TELEMINI 0x02
42 #define AO_TELEMETRY_SENSOR_TELENANO 0x03
44 struct ao_telemetry_sensor {
45 uint16_t serial; /* 0 */
46 uint16_t tick; /* 2 */
49 uint8_t state; /* 5 flight state */
50 int16_t accel; /* 6 accelerometer (TM only) */
51 int16_t pres; /* 8 pressure sensor */
52 int16_t temp; /* 10 temperature sensor */
53 int16_t v_batt; /* 12 battery voltage */
54 int16_t sense_d; /* 14 drogue continuity sense (TM/Tm) */
55 int16_t sense_m; /* 16 main continuity sense (TM/Tm) */
57 int16_t acceleration; /* 18 m/s² * 16 */
58 int16_t speed; /* 20 m/s * 16 */
59 int16_t height; /* 22 m */
61 int16_t ground_pres; /* 24 average pres on pad */
62 int16_t ground_accel; /* 26 average accel on pad */
63 int16_t accel_plus_g; /* 28 accel calibration at +1g */
64 int16_t accel_minus_g; /* 30 accel calibration at -1g */
68 #define AO_TELEMETRY_CONFIGURATION 0x04
70 struct ao_telemetry_configuration {
71 uint16_t serial; /* 0 */
72 uint16_t tick; /* 2 */
75 uint8_t device; /* 5 device type */
76 uint16_t flight; /* 6 flight number */
77 uint8_t config_major; /* 8 Config major version */
78 uint8_t config_minor; /* 9 Config minor version */
79 uint16_t apogee_delay; /* 10 Apogee deploy delay in seconds */
80 uint16_t main_deploy; /* 12 Main deploy alt in meters */
81 uint16_t flight_log_max; /* 14 Maximum flight log size in kB */
82 char callsign[AO_MAX_CALLSIGN]; /* 16 Radio operator identity */
83 char version[AO_MAX_VERSION]; /* 24 Software version */
87 #define AO_TELEMETRY_LOCATION 0x05
89 #define AO_GPS_MODE_NOT_VALID 'N'
90 #define AO_GPS_MODE_AUTONOMOUS 'A'
91 #define AO_GPS_MODE_DIFFERENTIAL 'D'
92 #define AO_GPS_MODE_ESTIMATED 'E'
93 #define AO_GPS_MODE_MANUAL 'M'
94 #define AO_GPS_MODE_SIMULATED 'S'
96 struct ao_telemetry_location {
97 uint16_t serial; /* 0 */
98 uint16_t tick; /* 2 */
101 uint8_t flags; /* 5 Number of sats and other flags */
102 int16_t altitude; /* 6 GPS reported altitude (m) */
103 int32_t latitude; /* 8 latitude (degrees * 10⁷) */
104 int32_t longitude; /* 12 longitude (degrees * 10⁷) */
105 uint8_t year; /* 16 (- 2000) */
106 uint8_t month; /* 17 (1-12) */
107 uint8_t day; /* 18 (1-31) */
108 uint8_t hour; /* 19 (0-23) */
109 uint8_t minute; /* 20 (0-59) */
110 uint8_t second; /* 21 (0-59) */
111 uint8_t pdop; /* 22 (m * 5) */
112 uint8_t hdop; /* 23 (m * 5) */
113 uint8_t vdop; /* 24 (m * 5) */
114 uint8_t mode; /* 25 */
115 uint16_t ground_speed; /* 26 cm/s */
116 int16_t climb_rate; /* 28 cm/s */
117 uint8_t course; /* 30 degrees / 2 */
118 uint8_t unused[1]; /* 31 */
122 #define AO_TELEMETRY_SATELLITE 0x06
124 struct ao_telemetry_satellite_info {
129 struct ao_telemetry_satellite {
130 uint16_t serial; /* 0 */
131 uint16_t tick; /* 2 */
132 uint8_t type; /* 4 */
133 uint8_t channels; /* 5 number of reported sats */
135 struct ao_telemetry_satellite_info sats[12]; /* 6 */
136 uint8_t unused[2]; /* 30 */
140 #define AO_TELEMETRY_COMPANION 0x07
142 #define AO_COMPANION_MAX_CHANNELS 12
144 struct ao_telemetry_companion {
145 uint16_t serial; /* 0 */
146 uint16_t tick; /* 2 */
147 uint8_t type; /* 4 */
148 uint8_t board_id; /* 5 */
150 uint8_t update_period; /* 6 */
151 uint8_t channels; /* 7 */
152 uint16_t companion_data[AO_COMPANION_MAX_CHANNELS]; /* 8 */
156 #define AO_TELEMETRY_MEGA_SENSOR 0x08
158 struct ao_telemetry_mega_sensor {
159 uint16_t serial; /* 0 */
160 uint16_t tick; /* 2 */
161 uint8_t type; /* 4 */
163 uint8_t pad5; /* 5 */
164 int16_t accel; /* 6 Z axis */
166 int32_t pres; /* 8 Pa * 10 */
167 int16_t temp; /* 12 °C * 100 */
169 int16_t accel_x; /* 14 */
170 int16_t accel_y; /* 16 */
171 int16_t accel_z; /* 18 */
173 int16_t gyro_x; /* 20 */
174 int16_t gyro_y; /* 22 */
175 int16_t gyro_z; /* 24 */
177 int16_t mag_x; /* 26 */
178 int16_t mag_y; /* 28 */
179 int16_t mag_z; /* 30 */
183 #define AO_TELEMETRY_MEGA_DATA 0x09
185 struct ao_telemetry_mega_data {
186 uint16_t serial; /* 0 */
187 uint16_t tick; /* 2 */
188 uint8_t type; /* 4 */
190 uint8_t state; /* 5 flight state */
192 int16_t v_batt; /* 6 battery voltage */
193 int16_t v_pyro; /* 8 pyro battery voltage */
194 int8_t sense[6]; /* 10 continuity sense */
196 int32_t ground_pres; /* 16 average pres on pad */
197 int16_t ground_accel; /* 20 average accel on pad */
198 int16_t accel_plus_g; /* 22 accel calibration at +1g */
199 int16_t accel_minus_g; /* 24 accel calibration at -1g */
201 int16_t acceleration; /* 26 m/s² * 16 */
202 int16_t speed; /* 28 m/s * 16 */
203 int16_t height; /* 30 m */
208 /* #define AO_SEND_ALL_BARO */
210 #define AO_TELEMETRY_BARO 0x80
213 * This packet allows the full sampling rate baro
214 * data to be captured over the RF link so that the
215 * flight software can be tested using 'real' data.
217 * Along with this telemetry packet, the flight
218 * code is modified to send full-rate telemetry all the time
219 * and never send an RDF tone; this ensure that the full radio
222 struct ao_telemetry_baro {
223 uint16_t serial; /* 0 */
224 uint16_t tick; /* 2 */
225 uint8_t type; /* 4 */
226 uint8_t samples; /* 5 number samples */
228 int16_t baro[12]; /* 6 samples */
232 union ao_telemetry_all {
233 struct ao_telemetry_generic generic;
234 struct ao_telemetry_sensor sensor;
235 struct ao_telemetry_configuration configuration;
236 struct ao_telemetry_location location;
237 struct ao_telemetry_satellite satellite;
238 struct ao_telemetry_companion companion;
239 struct ao_telemetry_mega_sensor mega_sensor;
240 struct ao_telemetry_mega_data mega_data;
241 struct ao_telemetry_baro baro;
244 struct ao_telemetry_all_recv {
245 union ao_telemetry_all telemetry;
250 #endif /* _AO_TELEMETRY_H_ */