From: Keith Packard Date: Sun, 26 Apr 2009 08:37:02 +0000 (-0700) Subject: Make sure full log is written and flushed on landing. X-Git-Tag: 0.1~5 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=5ed3b1cb52b573db1fee9655a29a0e6dd72f53fe;hp=2e737ad00cad5d893b252d8aa9dbff3d9b800731 Make sure full log is written and flushed on landing. The final state change to landing is recorded in the logging thread, so have that turn off logging once it has recorded that state. Then make it go to sleep. --- 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; diff --git a/ao_log.c b/ao_log.c index c74893f8..bcd852c0 100644 --- a/ao_log.c +++ b/ao_log.c @@ -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));