diff options
author | Jason Reiss <jreiss@multitech.com> | 2019-09-19 08:25:29 -0500 |
---|---|---|
committer | Jason Reiss <jreiss@multitech.com> | 2019-09-19 08:25:29 -0500 |
commit | c9df9ed22788a5ebca6fef270d9377e74737be1b (patch) | |
tree | 1e6572e8226f0188f4667b36ceef884ac619d8d8 /util_spectral_scan | |
parent | 660f8ec6a84315a75327458934d01276dd9d5ab9 (diff) | |
download | lora_gateway_mtac_full-c9df9ed22788a5ebca6fef270d9377e74737be1b.tar.gz lora_gateway_mtac_full-c9df9ed22788a5ebca6fef270d9377e74737be1b.tar.bz2 lora_gateway_mtac_full-c9df9ed22788a5ebca6fef270d9377e74737be1b.zip |
Apply patches for gpsd and spectral scan utility
Diffstat (limited to 'util_spectral_scan')
-rw-r--r-- | util_spectral_scan/src/util_spectral_scan.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/util_spectral_scan/src/util_spectral_scan.c b/util_spectral_scan/src/util_spectral_scan.c index d2aecda..cbc8377 100644 --- a/util_spectral_scan/src/util_spectral_scan.c +++ b/util_spectral_scan/src/util_spectral_scan.c @@ -30,6 +30,7 @@ Maintainer: Michael Coracin #include <stdlib.h> /* EXIT atoi */ #include <unistd.h> /* getopt */ #include <string.h> +#include <signal.h> #include "loragw_aux.h" #include "loragw_reg.h" @@ -66,11 +67,22 @@ Maintainer: Michael Coracin /* -------------------------------------------------------------------------- */ /* --- GLOBAL VARIABLES ----------------------------------------------------- */ +bool shutdown_signal_recv = false; + +void signalHandler() { + shutdown_signal_recv = true; +} + + /* -------------------------------------------------------------------------- */ /* --- MAIN FUNCTION -------------------------------------------------------- */ int main( int argc, char ** argv ) { + + signal(SIGINT, signalHandler); + signal(SIGTERM, signalHandler); + int i, j, k; /* loop and temporary variables */ int x; /* return code for functions */ int32_t reg_val; @@ -200,6 +212,10 @@ int main( int argc, char ** argv ) } } + if (shutdown_signal_recv) { + return 0; + } + /* Start message */ printf("+++ Start spectral scan of LoRa gateway channels +++\n"); @@ -264,7 +280,7 @@ int main( int argc, char ** argv ) printf("ERROR: Failed to disconnect from FPGA\n"); return EXIT_FAILURE; } - x = lgw_connect(false, LGW_DEFAULT_NOTCH_FREQ); /* FPGA reset/configure */ + x = lgw_connect(true, LGW_DEFAULT_NOTCH_FREQ); /* FPGA reset/configure */ if(x != 0) { printf("ERROR: Failed to connect to FPGA\n"); return EXIT_FAILURE; @@ -324,6 +340,9 @@ int main( int argc, char ** argv ) do { wait_ms(10); lgw_fpga_reg_r(LGW_FPGA_STATUS, ®_val); + if (shutdown_signal_recv) { + break; + } } while((TAKE_N_BITS_FROM((uint8_t)reg_val, 0, 5)) != 1); /* Clear has started */ @@ -346,6 +365,9 @@ int main( int argc, char ** argv ) do { wait_ms(1000); lgw_fpga_reg_r(LGW_FPGA_STATUS, ®_val); + if (shutdown_signal_recv) { + break; + } } while((TAKE_N_BITS_FROM((uint8_t)reg_val, 5, 1)) != 1); @@ -382,6 +404,10 @@ int main( int argc, char ** argv ) } fprintf(log_file, "\n"); printf("\n"); + + if (shutdown_signal_recv) { + break; + } } fclose(log_file); |