From 5ed3b1cb52b573db1fee9655a29a0e6dd72f53fe Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 26 Apr 2009 01:37:02 -0700 Subject: 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. --- ao_log.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'ao_log.c') 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)); -- cgit v1.2.3