diff options
author | Jason Reiss <jreiss@multitech.com> | 2018-08-02 07:45:58 -0500 |
---|---|---|
committer | Jason Reiss <jreiss@multitech.com> | 2018-08-02 07:45:58 -0500 |
commit | d48c010fe6c3ee0e3a6f2181d59507ffd786c0d9 (patch) | |
tree | b0a94da160c76ff131b6bda198c88c8b98d09f22 /recipes-connectivity | |
parent | 8b44a4cb9e7e0e1801a48025b476eb4572a6dabf (diff) | |
download | meta-mlinux-d48c010fe6c3ee0e3a6f2181d59507ffd786c0d9.tar.gz meta-mlinux-d48c010fe6c3ee0e3a6f2181d59507ffd786c0d9.tar.bz2 meta-mlinux-d48c010fe6c3ee0e3a6f2181d59507ffd786c0d9.zip |
lora: add signal handler for gracefull shutdown of spectral scan, otherwise hardware was left in bad state
Diffstat (limited to 'recipes-connectivity')
-rw-r--r-- | recipes-connectivity/lora/lora-gateway/lora-gateway-spectral-scan-skip-fpga-reset.patch | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/recipes-connectivity/lora/lora-gateway/lora-gateway-spectral-scan-skip-fpga-reset.patch b/recipes-connectivity/lora/lora-gateway/lora-gateway-spectral-scan-skip-fpga-reset.patch index 6e64ea6..e4a8b2b 100644 --- a/recipes-connectivity/lora/lora-gateway/lora-gateway-spectral-scan-skip-fpga-reset.patch +++ b/recipes-connectivity/lora/lora-gateway/lora-gateway-spectral-scan-skip-fpga-reset.patch @@ -2,7 +2,49 @@ diff --git a/util_spectral_scan/src/util_spectral_scan.c b/util_spectral_scan/sr index d2aecda..f070f4b 100644 --- a/util_spectral_scan/src/util_spectral_scan.c +++ b/util_spectral_scan/src/util_spectral_scan.c -@@ -264,7 +264,7 @@ int main( int argc, char ** argv ) +@@ -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; } @@ -11,4 +53,13 @@ index d2aecda..f070f4b 100644 if(x != 0) { printf("ERROR: Failed to connect to FPGA\n"); return EXIT_FAILURE; - +@@ -382,6 +398,10 @@ int main( int argc, char ** argv ) + } + fprintf(log_file, "\n"); + printf("\n"); ++ ++ if (shutdown_signal_recv) { ++ break; ++ } + } + fclose(log_file); |