2 * Copyright © 2014 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; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 #include <ao_log_gps.h>
23 #include <ao_flight.h>
24 #include <ao_distance.h>
25 #include <ao_tracker.h>
28 ao_log_gps_flight(void)
30 log.type = AO_LOG_FLIGHT;
32 log.u.flight.flight = ao_flight_number;
37 ao_log_gps_data(uint16_t tick, struct ao_telemetry_location *gps_data)
40 log.type = AO_LOG_GPS_TIME;
41 log.u.gps.latitude = gps_data->latitude;
42 log.u.gps.longitude = gps_data->longitude;
43 log.u.gps.altitude_low = gps_data->altitude_low;
44 log.u.gps.altitude_high = gps_data->altitude_high;
46 log.u.gps.hour = gps_data->hour;
47 log.u.gps.minute = gps_data->minute;
48 log.u.gps.second = gps_data->second;
49 log.u.gps.flags = gps_data->flags;
50 log.u.gps.year = gps_data->year;
51 log.u.gps.month = gps_data->month;
52 log.u.gps.day = gps_data->day;
53 log.u.gps.course = gps_data->course;
54 log.u.gps.ground_speed = gps_data->ground_speed;
55 log.u.gps.climb_rate = gps_data->climb_rate;
56 log.u.gps.pdop = gps_data->pdop;
57 log.u.gps.hdop = gps_data->hdop;
58 log.u.gps.vdop = gps_data->vdop;
59 log.u.gps.mode = gps_data->mode;
64 ao_log_gps_tracking(uint16_t tick, struct ao_telemetry_satellite *gps_tracking_data)
69 log.type = AO_LOG_GPS_SAT;
71 n = gps_tracking_data->channels;
72 for (c = 0; c < n; c++)
73 if ((log.u.gps_sat.sats[i].svid = gps_tracking_data->sats[c].svid))
75 log.u.gps_sat.sats[i].c_n = gps_tracking_data->sats[c].c_n_1;
80 log.u.gps_sat.channels = i;
85 ao_log_check(uint32_t pos)
87 if (!ao_storage_read(pos,
89 sizeof (struct ao_log_gps)))
90 return AO_LOG_INVALID;
92 if (ao_log_check_clear())
95 if (!ao_log_check_data())
96 return AO_LOG_INVALID;