From b0ec30de37aa822ba66d25ceaa8cf8dc967b4371 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 13 Aug 2011 18:31:08 -0700 Subject: [PATCH] altos: wait 10s for companion to boot In case the companion is delayed while booting, retry the setup 10 times with a 1s delay between tries. Signed-off-by: Keith Packard --- src/ao_companion.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ao_companion.c b/src/ao_companion.c index 8f23ba25..4c8f4269 100644 --- a/src/ao_companion.c +++ b/src/ao_companion.c @@ -81,7 +81,14 @@ ao_companion_notify(void) void ao_companion(void) { - ao_companion_running = ao_companion_get_setup(); + uint8_t i; + while (!ao_flight_number) + ao_sleep(&ao_flight_number); + for (i = 0; i < 10; i++) { + ao_delay(AO_SEC_TO_TICKS(1)); + if ((ao_companion_running = ao_companion_get_setup())) + break; + } while (ao_companion_running) { ao_alarm(ao_companion_setup.update_period); if (ao_sleep(DATA_TO_XDATA(&ao_flight_state))) -- 2.30.2