From a32deb8ba7ce6987a7964958c079f3dc078fa0c8 Mon Sep 17 00:00:00 2001 From: Harsh Sharma Date: Wed, 11 Sep 2019 13:02:09 -0500 Subject: Changed lgw receive to try until reset counter before exiting --- lora_pkt_fwd/src/lora_pkt_fwd.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lora_pkt_fwd/src/lora_pkt_fwd.c b/lora_pkt_fwd/src/lora_pkt_fwd.c index 3b92b27..f26a51a 100644 --- a/lora_pkt_fwd/src/lora_pkt_fwd.c +++ b/lora_pkt_fwd/src/lora_pkt_fwd.c @@ -141,6 +141,7 @@ Maintainer: Michael Coracin #define HISTOGRAM_CLEAN_TIMEOUT 10000 #define HISTOGRAM_READY_TIMEOUT 1000 +#define LGW_RECEIVE_TIMEOUT 100 /* -------------------------------------------------------------------------- */ /* --- PRIVATE VARIABLES (GLOBAL) ------------------------------------------- */ @@ -1648,6 +1649,7 @@ void thread_up(void) { struct lgw_pkt_rx_s rxpkt[NB_PKT_MAX]; /* array containing inbound packets + metadata */ struct lgw_pkt_rx_s *p; /* pointer on a RX packet */ int nb_pkt; + uint8_t lgw_receive_counter = 0; /* local copy of GPS time reference */ bool ref_ok = false; /* determine if GPS time reference must be used or not */ @@ -1694,13 +1696,18 @@ void thread_up(void) { while (!exit_sig && !quit_sig) { + if(lgw_receive_counter > LGW_RECEIVE_TIMEOUT) { + MSG("ERROR: [up] lgw_receive_counter limit reached, exiting\n"); + exit(EXIT_FAILURE); + } /* fetch packets */ pthread_mutex_lock(&mx_concent); nb_pkt = lgw_receive(NB_PKT_MAX, rxpkt); pthread_mutex_unlock(&mx_concent); if (nb_pkt == LGW_HAL_ERROR) { - MSG("ERROR: [up] failed packet fetch, exiting\n"); - exit(EXIT_FAILURE); + MSG("ERROR: [up] failed packet fetch, retrying\n"); + lgw_receive_counter++; + wait_ms(1000); } /* check if there are status report to send */ -- cgit v1.2.3