This wakes up the two GPS reporting tasks and gets them to report out
any existing GPS data to the log file. To make sure the timestamps in
that GPS data are accurate, this also records GPS time on receipt of
the GPS data instead of when that is logged.
Signed-off-by: Keith Packard <keithp@keithp.com>
#define AO_GPS_RUNNING (1 << 5)
#define AO_GPS_DATE_VALID (1 << 6)
#define AO_GPS_RUNNING (1 << 5)
#define AO_GPS_DATE_VALID (1 << 6)
+extern __xdata uint16_t ao_gps_tick;
+
struct ao_gps_data {
uint8_t year;
uint8_t month;
struct ao_gps_data {
uint8_t year;
uint8_t month;
/* disable RDF beacon */
ao_rdf_set(0);
/* disable RDF beacon */
ao_rdf_set(0);
+ /* Record current GPS position by waking up GPS log tasks */
+ ao_wakeup(&ao_gps_data);
+ ao_wakeup(&ao_gps_tracking_data);
+
ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
break;
}
ao_wakeup(DATA_TO_XDATA(&ao_flight_state));
break;
}
if (!(gps_data.flags & AO_GPS_VALID))
continue;
if (!(gps_data.flags & AO_GPS_VALID))
continue;
- gps_log.tick = ao_time();
+ gps_log.tick = ao_gps_tick;
gps_log.type = AO_LOG_GPS_TIME;
gps_log.u.gps_time.hour = gps_data.hour;
gps_log.u.gps_time.minute = gps_data.minute;
gps_log.type = AO_LOG_GPS_TIME;
gps_log.u.gps_time.hour = gps_data.hour;
gps_log.u.gps_time.minute = gps_data.minute;
for (;;) {
ao_sleep(&ao_gps_tracking_data);
ao_mutex_get(&ao_gps_mutex);
for (;;) {
ao_sleep(&ao_gps_tracking_data);
ao_mutex_get(&ao_gps_mutex);
+ gps_log.tick = ao_gps_tick;
memcpy(&gps_tracking_data, &ao_gps_tracking_data, sizeof (struct ao_gps_tracking_data));
ao_mutex_put(&ao_gps_mutex);
if (!(n = gps_tracking_data.channels))
continue;
memcpy(&gps_tracking_data, &ao_gps_tracking_data, sizeof (struct ao_gps_tracking_data));
ao_mutex_put(&ao_gps_mutex);
if (!(n = gps_tracking_data.channels))
continue;
- gps_log.tick = ao_time();
gps_log.type = AO_LOG_GPS_SAT;
for (c = 0; c < n; c++)
if ((gps_log.u.gps_sat.svid = gps_tracking_data.sats[c].svid))
gps_log.type = AO_LOG_GPS_SAT;
for (c = 0; c < n; c++)
if ((gps_log.u.gps_sat.svid = gps_tracking_data.sats[c].svid))
#endif
__xdata uint8_t ao_gps_mutex;
#endif
__xdata uint8_t ao_gps_mutex;
+__xdata uint16_t ao_gps_tick;
__xdata struct ao_gps_data ao_gps_data;
__xdata struct ao_gps_tracking_data ao_gps_tracking_data;
__xdata struct ao_gps_data ao_gps_data;
__xdata struct ao_gps_tracking_data ao_gps_tracking_data;
switch (i) {
case 41:
ao_mutex_get(&ao_gps_mutex);
switch (i) {
case 41:
ao_mutex_get(&ao_gps_mutex);
+ ao_gps_tick = ao_time();
ao_gps_data.hour = ao_sirf_data.utc_hour;
ao_gps_data.minute = ao_sirf_data.utc_minute;
ao_gps_data.second = ao_sirf_data.utc_second / 1000;
ao_gps_data.hour = ao_sirf_data.utc_hour;
ao_gps_data.minute = ao_sirf_data.utc_minute;
ao_gps_data.second = ao_sirf_data.utc_second / 1000;
static __xdata uint8_t ao_gps_cksum;
static __xdata uint8_t ao_gps_error;
static __xdata uint8_t ao_gps_cksum;
static __xdata uint8_t ao_gps_error;
+__xdata uint16_t ao_gps_tick;
__xdata struct ao_gps_data ao_gps_data;
__xdata struct ao_gps_tracking_data ao_gps_tracking_data;
__xdata struct ao_gps_data ao_gps_data;
__xdata struct ao_gps_tracking_data ao_gps_tracking_data;
+static __xdata uint16_t ao_gps_next_tick;
static __xdata struct ao_gps_data ao_gps_next;
static __xdata uint8_t ao_gps_date_flags;
static __xdata struct ao_gps_tracking_data ao_gps_tracking_next;
static __xdata struct ao_gps_data ao_gps_next;
static __xdata uint8_t ao_gps_date_flags;
static __xdata struct ao_gps_tracking_data ao_gps_tracking_next;
+ ao_gps_next_tick = ao_time();
ao_gps_next.flags = AO_GPS_RUNNING | ao_gps_date_flags;
ao_gps_next.hour = ao_gps_decimal(2);
ao_gps_next.minute = ao_gps_decimal(2);
ao_gps_next.flags = AO_GPS_RUNNING | ao_gps_date_flags;
ao_gps_next.hour = ao_gps_decimal(2);
ao_gps_next.minute = ao_gps_decimal(2);
ao_gps_error = 1;
if (!ao_gps_error) {
ao_mutex_get(&ao_gps_mutex);
ao_gps_error = 1;
if (!ao_gps_error) {
ao_mutex_get(&ao_gps_mutex);
+ ao_gps_tick = ao_gps_next_tick;
memcpy(&ao_gps_data, &ao_gps_next, sizeof (struct ao_gps_data));
ao_mutex_put(&ao_gps_mutex);
ao_wakeup(&ao_gps_data);
memcpy(&ao_gps_data, &ao_gps_next, sizeof (struct ao_gps_data));
ao_mutex_put(&ao_gps_mutex);
ao_wakeup(&ao_gps_data);
#include "ao_gps_print.c"
#include "ao_gps_sirf.c"
#include "ao_gps_print.c"
#include "ao_gps_sirf.c"
#include "ao_gps_print.c"
#include "ao_gps_skytraq.c"
#include "ao_gps_print.c"
#include "ao_gps_skytraq.c"