2 * Copyright © 2010 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 package org.altusmetrum.AltosLib;
23 * Telemetry data contents
28 * The packet format is a simple hex dump of the raw telemetry frame.
29 * It starts with 'TELEM', then contains hex digits with a checksum as the last
32 * Version 4 is a replacement with consistent syntax. Each telemetry line
33 * contains a sequence of space-separated names and values, the values are
34 * either integers or strings. The names are all unique. All values are
37 * VERSION 4 c KD7SQG n 236 f 18 r -25 s pad t 513 r_a 15756 r_b 26444 r_t 20944
38 * r_v 26640 r_d 512 r_m 208 c_a 15775 c_b 26439 c_p 15749 c_m 16281 a_a 15764
39 * a_s 0 a_b 26439 g_s u g_n 0 s_n 0
41 * VERSION 4 c KD7SQG n 19 f 0 r -23 s pad t 513 r_b 26372 r_t 21292 r_v 26788
42 * r_d 136 r_m 140 c_b 26370 k_h 0 k_s 0 k_a 0
44 * General header fields
48 * VERSION Telemetry version number (4 or more). Must be first.
49 * c Callsign (string, no spaces allowed)
50 * n Flight unit serial number (integer)
51 * f Flight number (integer)
52 * r Packet RSSI value (integer)
53 * s Flight computer state (string, no spaces allowed)
54 * t Flight computer clock (integer in centiseconds)
56 * Version 3 is Version 2 with fixed RSSI numbers -- the radio reports
57 * in 1/2dB increments while this protocol provides only integers. So,
58 * the syntax didn't change just the interpretation of the RSSI
61 * Version 2 of the telemetry data stream is a bit of a mess, with no
62 * consistent formatting. In particular, the GPS data is formatted for
63 * viewing instead of parsing. However, the key feature is that every
64 * telemetry line contains all of the information necessary to
65 * describe the current rocket state, including the calibration values
66 * for accelerometer and barometer.
70 * VERSION 2 CALL KB0G SERIAL 51 FLIGHT 2 RSSI -68 STATUS ff STATE pad 1001 \
71 * a: 16032 p: 21232 t: 20284 v: 25160 d: 204 m: 204 fa: 16038 ga: 16032 fv: 0 \
72 * fp: 21232 gp: 21230 a+: 16049 a-: 16304 GPS 0 sat unlocked SAT 1 15 30
76 * VERSION 2 CALL KB0G SERIAL 51 FLIGHT 2 RSSI -71 STATUS ff STATE pad 2504 \
77 * a: 16028 p: 21220 t: 20360 v: 25004 d: 208 m: 200 fa: 16031 ga: 16032 fv: 330 \
78 * fp: 21231 gp: 21230 a+: 16049 a-: 16304 \
79 * GPS 9 sat 2010-02-13 17:16:51 35°20.0803'N 106°45.2235'W 1790m \
80 * 0.00m/s(H) 0° 0.00m/s(V) 1.0(hdop) 0(herr) 0(verr) \
81 * SAT 10 29 30 24 28 5 25 21 20 15 33 1 23 30 24 18 26 10 29 2 26
85 public abstract class AltosTelemetry extends AltosRecord {
88 * General header fields
92 * VERSION Telemetry version number (4 or more). Must be first.
93 * c Callsign (string, no spaces allowed)
94 * n Flight unit serial number (integer)
95 * f Flight number (integer)
96 * r Packet RSSI value (integer)
97 * s Flight computer state (string, no spaces allowed)
98 * t Flight computer clock (integer in centiseconds)
101 final static String AO_TELEM_VERSION = "VERSION";
102 final static String AO_TELEM_CALL = "c";
103 final static String AO_TELEM_SERIAL = "n";
104 final static String AO_TELEM_FLIGHT = "f";
105 final static String AO_TELEM_RSSI = "r";
106 final static String AO_TELEM_STATE = "s";
107 final static String AO_TELEM_TICK = "t";
113 * r_a Accelerometer reading (integer)
114 * r_b Barometer reading (integer)
115 * r_t Thermometer reading (integer)
116 * r_v Battery reading (integer)
117 * r_d Drogue continuity (integer)
118 * r_m Main continuity (integer)
121 final static String AO_TELEM_RAW_ACCEL = "r_a";
122 final static String AO_TELEM_RAW_BARO = "r_b";
123 final static String AO_TELEM_RAW_THERMO = "r_t";
124 final static String AO_TELEM_RAW_BATT = "r_v";
125 final static String AO_TELEM_RAW_DROGUE = "r_d";
126 final static String AO_TELEM_RAW_MAIN = "r_m";
129 * Sensor calibration values
132 * c_a Ground accelerometer reading (integer)
133 * c_b Ground barometer reading (integer)
134 * c_p Accelerometer reading for +1g
135 * c_m Accelerometer reading for -1g
138 final static String AO_TELEM_CAL_ACCEL_GROUND = "c_a";
139 final static String AO_TELEM_CAL_BARO_GROUND = "c_b";
140 final static String AO_TELEM_CAL_ACCEL_PLUS = "c_p";
141 final static String AO_TELEM_CAL_ACCEL_MINUS = "c_m";
144 * Kalman state values
147 * k_h Height above pad (integer, meters)
148 * k_s Vertical speeed (integer, m/s * 16)
149 * k_a Vertical acceleration (integer, m/s² * 16)
152 final static String AO_TELEM_KALMAN_HEIGHT = "k_h";
153 final static String AO_TELEM_KALMAN_SPEED = "k_s";
154 final static String AO_TELEM_KALMAN_ACCEL = "k_a";
157 * Ad-hoc flight values
160 * a_a Acceleration (integer, sensor units)
161 * a_s Speed (integer, integrated acceleration value)
162 * a_b Barometer reading (integer, sensor units)
165 final static String AO_TELEM_ADHOC_ACCEL = "a_a";
166 final static String AO_TELEM_ADHOC_SPEED = "a_s";
167 final static String AO_TELEM_ADHOC_BARO = "a_b";
173 * g_s GPS state (string):
176 * e error (missing or broken)
177 * g_n Number of sats used in solution
178 * g_ns Latitude (degrees * 10e7)
179 * g_ew Longitude (degrees * 10e7)
180 * g_a Altitude (integer meters)
181 * g_Y GPS year (integer)
182 * g_M GPS month (integer - 1-12)
183 * g_D GPS day (integer - 1-31)
184 * g_h GPS hour (integer - 0-23)
185 * g_m GPS minute (integer - 0-59)
186 * g_s GPS second (integer - 0-59)
187 * g_v GPS vertical speed (integer, cm/sec)
188 * g_s GPS horizontal speed (integer, cm/sec)
189 * g_c GPS course (integer, 0-359)
190 * g_hd GPS hdop (integer * 10)
191 * g_vd GPS vdop (integer * 10)
192 * g_he GPS h error (integer)
193 * g_ve GPS v error (integer)
196 final static String AO_TELEM_GPS_STATE = "g";
197 final static String AO_TELEM_GPS_STATE_LOCKED = "l";
198 final static String AO_TELEM_GPS_STATE_UNLOCKED = "u";
199 final static String AO_TELEM_GPS_STATE_ERROR = "e";
200 final static String AO_TELEM_GPS_NUM_SAT = "g_n";
201 final static String AO_TELEM_GPS_LATITUDE = "g_ns";
202 final static String AO_TELEM_GPS_LONGITUDE = "g_ew";
203 final static String AO_TELEM_GPS_ALTITUDE = "g_a";
204 final static String AO_TELEM_GPS_YEAR = "g_Y";
205 final static String AO_TELEM_GPS_MONTH = "g_M";
206 final static String AO_TELEM_GPS_DAY = "g_D";
207 final static String AO_TELEM_GPS_HOUR = "g_h";
208 final static String AO_TELEM_GPS_MINUTE = "g_m";
209 final static String AO_TELEM_GPS_SECOND = "g_s";
210 final static String AO_TELEM_GPS_VERTICAL_SPEED = "g_v";
211 final static String AO_TELEM_GPS_HORIZONTAL_SPEED = "g_g";
212 final static String AO_TELEM_GPS_COURSE = "g_c";
213 final static String AO_TELEM_GPS_HDOP = "g_hd";
214 final static String AO_TELEM_GPS_VDOP = "g_vd";
215 final static String AO_TELEM_GPS_HERROR = "g_he";
216 final static String AO_TELEM_GPS_VERROR = "g_ve";
219 * GPS satellite values
222 * s_n Number of satellites reported (integer)
223 * s_v0 Space vehicle ID (integer) for report 0
224 * s_c0 C/N0 number (integer) for report 0
225 * s_v1 Space vehicle ID (integer) for report 1
226 * s_c1 C/N0 number (integer) for report 1
230 final static String AO_TELEM_SAT_NUM = "s_n";
231 final static String AO_TELEM_SAT_SVID = "s_v";
232 final static String AO_TELEM_SAT_C_N_0 = "s_c";
234 static public AltosRecord parse(String line, AltosRecord previous) throws ParseException, AltosCRCException {
235 AltosTelemetryRecord r = AltosTelemetryRecord.parse(line);
237 return r.update_state(previous);