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.
25 cc_fullname (char *dir, char *file);
28 cc_basename(char *file);
38 int serial; /* AltOS always uses simple integer serial numbers */
44 struct cc_usbdev **dev;
49 cc_usbdevs_free(struct cc_usbdevs *usbdevs);
52 cc_usbdevs_scan(void);
55 cc_usbdevs_find_by_arg(char *arg, char *default_product);
58 cc_set_log_dir(char *dir);
64 cc_make_filename(int serial, char *ext);
67 * For sequential data which are not evenly spaced
70 struct cc_timedataelt {
78 struct cc_timedataelt *data;
98 #define SIRF_SAT_STATE_ACQUIRED (1 << 0)
99 #define SIRF_SAT_STATE_CARRIER_PHASE_VALID (1 << 1)
100 #define SIRF_SAT_BIT_SYNC_COMPLETE (1 << 2)
101 #define SIRF_SAT_SUBFRAME_SYNC_COMPLETE (1 << 3)
102 #define SIRF_SAT_CARRIER_PULLIN_COMPLETE (1 << 4)
103 #define SIRF_SAT_CODE_LOCKED (1 << 5)
104 #define SIRF_SAT_ACQUISITION_FAILED (1 << 6)
105 #define SIRF_SAT_EPHEMERIS_AVAILABLE (1 << 7)
115 struct cc_gpssat sat[12];
121 struct cc_gpselt *data;
125 struct cc_gpssats *sats;
129 * For sequential data which are evenly spaced
131 struct cc_perioddata {
138 enum ao_flight_state {
139 ao_flight_startup = 0,
145 ao_flight_drogue = 6,
147 ao_flight_landed = 8,
148 ao_flight_invalid = 9
151 struct cc_flightraw {
156 int year, month, day;
157 struct cc_timedata accel;
158 struct cc_timedata pres;
159 struct cc_timedata temp;
160 struct cc_timedata volt;
161 struct cc_timedata main;
162 struct cc_timedata drogue;
163 struct cc_timedata state;
164 struct cc_gpsdata gps;
167 struct cc_flightraw *
168 cc_log_read(FILE *file);
171 cc_flightraw_free(struct cc_flightraw *raw);
173 struct cc_flightcooked {
177 struct cc_perioddata accel_accel;
178 struct cc_perioddata accel_speed;
179 struct cc_perioddata accel_pos;
180 struct cc_perioddata pres_pos;
181 struct cc_perioddata pres_speed;
182 struct cc_perioddata pres_accel;
183 struct cc_perioddata gps_lat;
184 struct cc_perioddata gps_lon;
185 struct cc_perioddata gps_alt;
187 /* unfiltered, but converted */
188 struct cc_timedata pres;
189 struct cc_timedata accel;
190 struct cc_timedata state;
194 * Telemetry data contents
211 struct cc_gps_time gps_time;
212 double lat; /* degrees (+N -S) */
213 double lon; /* degrees (+E -W) */
216 int gps_extended; /* has extra data */
217 double ground_speed; /* m/s */
218 int course; /* degrees */
219 double climb_rate; /* m/s */
220 double hdop; /* unitless? */
225 #define SIRF_SAT_STATE_ACQUIRED (1 << 0)
226 #define SIRF_SAT_STATE_CARRIER_PHASE_VALID (1 << 1)
227 #define SIRF_SAT_BIT_SYNC_COMPLETE (1 << 2)
228 #define SIRF_SAT_SUBFRAME_SYNC_COMPLETE (1 << 3)
229 #define SIRF_SAT_CARRIER_PULLIN_COMPLETE (1 << 4)
230 #define SIRF_SAT_CODE_LOCKED (1 << 5)
231 #define SIRF_SAT_ACQUISITION_FAILED (1 << 6)
232 #define SIRF_SAT_EPHEMERIS_AVAILABLE (1 << 7)
240 struct cc_gps_tracking {
242 struct cc_gps_sat sats[12];
266 struct cc_gps_tracking gps_tracking;
270 cc_telem_parse(const char *input_line, struct cc_telem *telem);
277 /* Conversion functions */
279 cc_pressure_to_altitude(double pressure);
282 cc_altitude_to_pressure(double altitude);
285 cc_barometer_to_pressure(double baro);
288 cc_barometer_to_altitude(double baro);
291 cc_accelerometer_to_acceleration(double accel, double ground_accel);
294 cc_thermometer_to_temperature(double thermo);
297 cc_battery_to_voltage(double battery);
300 cc_ignitor_to_voltage(double ignite);
303 cc_great_circle (double start_lat, double start_lon,
304 double end_lat, double end_lon,
305 double *dist, double *bearing);
308 cc_timedata_limits(struct cc_timedata *d, double min_time, double max_time, int *start, int *stop);
311 cc_timedata_min(struct cc_timedata *d, double min_time, double max_time);
314 cc_timedata_min_mag(struct cc_timedata *d, double min_time, double max_time);
317 cc_timedata_max(struct cc_timedata *d, double min_time, double max_time);
320 cc_timedata_max_mag(struct cc_timedata *d, double min_time, double max_time);
323 cc_timedata_average(struct cc_timedata *d, double min_time, double max_time);
326 cc_timedata_average_mag(struct cc_timedata *d, double min_time, double max_time);
329 cc_perioddata_limits(struct cc_perioddata *d, double min_time, double max_time, int *start, int *stop);
332 cc_perioddata_min(struct cc_perioddata *d, double min_time, double max_time);
335 cc_perioddata_min_mag(struct cc_perioddata *d, double min_time, double max_time);
338 cc_perioddata_max(struct cc_perioddata *d, double min_time, double max_time);
341 cc_perioddata_max_mag(struct cc_perioddata *d, double min_time, double max_time);
344 cc_perioddata_average(struct cc_perioddata *d, double min_time, double max_time);
347 cc_perioddata_average_mag(struct cc_perioddata *d, double min_time, double max_time);
350 cc_low_pass(double *data, int data_len, double omega_pass, double omega_stop, double error);
352 struct cc_perioddata *
353 cc_period_make(struct cc_timedata *td, double start_time, double stop_time);
355 struct cc_perioddata *
356 cc_period_low_pass(struct cc_perioddata *raw, double omega_pass, double omega_stop, double error);
359 cc_timedata_convert(struct cc_timedata *d, double (*f)(double v, double a), double a);
362 cc_timedata_integrate(struct cc_timedata *d, double min_time, double max_time);
364 struct cc_perioddata *
365 cc_perioddata_differentiate(struct cc_perioddata *i);
367 struct cc_flightcooked *
368 cc_flight_cook(struct cc_flightraw *raw);
371 cc_flightcooked_free(struct cc_flightcooked *cooked);