From 7ce244e7ca2707757e0530ed745d755eb569f7e9 Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Tue, 20 Sep 2016 10:27:28 +0200 Subject: [PATCH] [gps] update global gps struct from periodic check thanks to fvantienen --- sw/airborne/subsystems/gps.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/sw/airborne/subsystems/gps.c b/sw/airborne/subsystems/gps.c index f9d43d11cbb..facf24e8631 100644 --- a/sw/airborne/subsystems/gps.c +++ b/sw/airborne/subsystems/gps.c @@ -175,12 +175,6 @@ static void send_gps_sol(struct transport_tx *trans, struct link_device *dev) } #endif -void gps_periodic_check(struct GpsState *gps_s) -{ - if (sys_time.nb_sec - gps_s->last_msg_time > GPS_TIMEOUT) { - gps_s->fix = GPS_FIX_NONE; - } -} #ifdef SECONDARY_GPS static uint8_t gps_multi_switch(struct GpsState *gps_s) { @@ -211,6 +205,24 @@ static uint8_t gps_multi_switch(struct GpsState *gps_s) { } #endif /*SECONDARY_GPS*/ + +void gps_periodic_check(struct GpsState *gps_s) +{ + if (sys_time.nb_sec - gps_s->last_msg_time > GPS_TIMEOUT) { + gps_s->fix = GPS_FIX_NONE; + } + +#ifdef SECONDARY_GPS + current_gps_id = gps_multi_switch(gps_s); + if (gps_s->comp_id == current_gps_id) { + gps = *gps_s; + } +#else + gps = *gps_s; +#endif +} + + static abi_event gps_ev; static void gps_cb(uint8_t sender_id, uint32_t stamp __attribute__((unused)),