diff options
-rw-r--r-- | ao_flight.c | 3 | ||||
-rw-r--r-- | ao_gps_report.c | 3 | ||||
-rw-r--r-- | ao_log.c | 24 |
3 files changed, 18 insertions, 12 deletions
diff --git a/ao_flight.c b/ao_flight.c index 01bbcce9..37c138fe 100644 --- a/ao_flight.c +++ b/ao_flight.c @@ -408,9 +408,6 @@ ao_flight(void) /* turn off the ADC capture */ ao_timer_set_adc_interval(0); - /* stop logging data */ - ao_log_stop(); - ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); } break; diff --git a/ao_gps_report.c b/ao_gps_report.c index 494714b6..1b5402a8 100644 --- a/ao_gps_report.c +++ b/ao_gps_report.c @@ -29,6 +29,9 @@ ao_gps_report(void) memcpy(&gps_data, &ao_gps_data, sizeof (struct ao_gps_data)); ao_mutex_put(&ao_gps_mutex); + if (!(gps_data.flags & AO_GPS_VALID)) + continue; + gps_log.tick = ao_time(); gps_log.type = AO_LOG_GPS_TIME; gps_log.u.gps_time.hour = gps_data.hour; @@ -125,15 +125,9 @@ ao_log(void) log.u.flight.flight = ao_log_dump_flight + 1; ao_log_data(&log); for (;;) { - /* Write state change to EEPROM */ - if (ao_flight_state != ao_log_state) { - ao_log_state = ao_flight_state; - log.type = AO_LOG_STATE; - log.tick = ao_flight_tick; - log.u.state.state = ao_log_state; - log.u.state.reason = 0; - ao_log_data(&log); - } + while (!ao_log_running) + ao_sleep(&ao_log_running); + /* Write samples to EEPROM */ while (ao_log_adc_pos != ao_adc_head) { log.type = AO_LOG_SENSOR; @@ -155,6 +149,18 @@ ao_log(void) } ao_log_adc_pos = ao_adc_ring_next(ao_log_adc_pos); } + /* Write state change to EEPROM */ + if (ao_flight_state != ao_log_state) { + ao_log_state = ao_flight_state; + log.type = AO_LOG_STATE; + log.tick = ao_flight_tick; + log.u.state.state = ao_log_state; + log.u.state.reason = 0; + ao_log_data(&log); + + if (ao_log_state == ao_flight_landed) + ao_log_stop(); + } /* Wait for a while */ ao_delay(AO_MS_TO_TICKS(100)); |