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.
24 cc_fullname (char *dir, char *file);
27 cc_basename(char *file);
37 int serial; /* AltOS always uses simple integer serial numbers */
43 struct cc_usbdev **dev;
48 cc_usbdevs_free(struct cc_usbdevs *usbdevs);
51 cc_usbdevs_scan(void);
54 cc_usbdevs_find_by_arg(char *arg, char *default_product);
57 cc_set_log_dir(char *dir);
63 cc_make_filename(int serial, char *ext);
66 * For sequential data which are not evenly spaced
69 struct cc_timedataelt {
77 struct cc_timedataelt *data;
96 struct cc_gpselt *data;
101 * For sequential data which are evenly spaced
103 struct cc_perioddata {
110 enum ao_flight_state {
111 ao_flight_startup = 0,
117 ao_flight_drogue = 6,
119 ao_flight_landed = 8,
120 ao_flight_invalid = 9
123 struct cc_flightraw {
128 struct cc_timedata accel;
129 struct cc_timedata pres;
130 struct cc_timedata temp;
131 struct cc_timedata volt;
132 struct cc_timedata main;
133 struct cc_timedata drogue;
134 struct cc_timedata state;
135 struct cc_gpsdata gps;
138 struct cc_flightraw *
139 cc_log_read(FILE *file);
142 cc_flightraw_free(struct cc_flightraw *raw);
144 struct cc_flightcooked {
145 struct cc_perioddata accel_accel;
146 struct cc_perioddata accel_speed;
147 struct cc_perioddata accel_pos;
148 struct cc_perioddata pres_pos;
149 struct cc_perioddata pres_speed;
150 struct cc_perioddata pres_accel;
151 struct cc_perioddata gps_lat;
152 struct cc_perioddata gps_lon;
153 struct cc_perioddata gps_alt;
154 struct cc_timedata state;
158 * Telemetry data contents
172 struct cc_gps_time gps_time;
173 double lat; /* degrees (+N -S) */
174 double lon; /* degrees (+E -W) */
177 int gps_extended; /* has extra data */
178 double ground_speed; /* m/s */
179 int course; /* degrees */
180 double climb_rate; /* m/s */
181 double hdop; /* unitless? */
186 #define SIRF_SAT_STATE_ACQUIRED (1 << 0)
187 #define SIRF_SAT_STATE_CARRIER_PHASE_VALID (1 << 1)
188 #define SIRF_SAT_BIT_SYNC_COMPLETE (1 << 2)
189 #define SIRF_SAT_SUBFRAME_SYNC_COMPLETE (1 << 3)
190 #define SIRF_SAT_CARRIER_PULLIN_COMPLETE (1 << 4)
191 #define SIRF_SAT_CODE_LOCKED (1 << 5)
192 #define SIRF_SAT_ACQUISITION_FAILED (1 << 6)
193 #define SIRF_SAT_EPHEMERIS_AVAILABLE (1 << 7)
201 struct cc_gps_tracking {
203 struct cc_gps_sat sats[12];
224 struct cc_gps_tracking gps_tracking;
228 cc_telem_parse(const char *input_line, struct cc_telem *telem);
235 /* Conversion functions */
237 cc_pressure_to_altitude(double pressure);
240 cc_altitude_to_pressure(double altitude);
243 cc_barometer_to_pressure(double baro);
246 cc_barometer_to_altitude(double baro);
249 cc_accelerometer_to_acceleration(double accel, double ground_accel);
252 cc_thermometer_to_temperature(double thermo);
255 cc_battery_to_voltage(double battery);
258 cc_ignitor_to_voltage(double ignite);
261 cc_great_circle (double start_lat, double start_lon,
262 double end_lat, double end_lon,
263 double *dist, double *bearing);
266 cc_timedata_min(struct cc_timedata *d, double min_time, double max_time);
269 cc_timedata_max(struct cc_timedata *d, double min_time, double max_time);
272 cc_perioddata_min(struct cc_perioddata *d, double min_time, double max_time);
275 cc_perioddata_max(struct cc_perioddata *d, double min_time, double max_time);
278 cc_low_pass(double *data, int data_len, double omega_pass, double omega_stop, double error);
280 struct cc_perioddata *
281 cc_period_make(struct cc_timedata *td, double start_time, double stop_time);
283 struct cc_perioddata *
284 cc_period_low_pass(struct cc_perioddata *raw, double omega_pass, double omega_stop, double error);
287 cc_timedata_convert(struct cc_timedata *d, double (*f)(double v, double a), double a);
290 cc_timedata_integrate(struct cc_timedata *d);
292 struct cc_perioddata *
293 cc_perioddata_differentiate(struct cc_perioddata *i);
295 struct cc_flightcooked *
296 cc_flight_cook(struct cc_flightraw *raw);