diff options
author | Jason Reiss <jreiss@multitech.com> | 2020-03-20 09:11:25 -0500 |
---|---|---|
committer | Jason Reiss <jreiss@multitech.com> | 2020-03-20 09:11:25 -0500 |
commit | ea028e8048d55367a52365087f9e3928746c55a5 (patch) | |
tree | d3c28fb745071653bcf35bff7f05c93051796390 /util_spectral_scan/src/util_spectral_scan.c | |
parent | b3a4461b3dfc5588111a88fd735d058888b8d3d4 (diff) | |
parent | dea57d6f29246434173c33c56850708c51fc5b23 (diff) | |
download | lora_gateway_mtac_full-ea028e8048d55367a52365087f9e3928746c55a5.tar.gz lora_gateway_mtac_full-ea028e8048d55367a52365087f9e3928746c55a5.tar.bz2 lora_gateway_mtac_full-ea028e8048d55367a52365087f9e3928746c55a5.zip |
Merge branch 'master' of gitlab.multitech.net:lora_enterprise/lora_gateway_mtac_full5.0.1-mts-5
Diffstat (limited to 'util_spectral_scan/src/util_spectral_scan.c')
-rw-r--r-- | util_spectral_scan/src/util_spectral_scan.c | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/util_spectral_scan/src/util_spectral_scan.c b/util_spectral_scan/src/util_spectral_scan.c index cbc8377..090dc22 100644 --- a/util_spectral_scan/src/util_spectral_scan.c +++ b/util_spectral_scan/src/util_spectral_scan.c @@ -31,12 +31,14 @@ Maintainer: Michael Coracin #include <unistd.h> /* getopt */ #include <string.h> #include <signal.h> +#include <getopt.h> /* getopt_long */ #include "loragw_aux.h" #include "loragw_reg.h" #include "loragw_hal.h" #include "loragw_radio.h" #include "loragw_fpga.h" +#include "loragw_spi.h" /* -------------------------------------------------------------------------- */ /* --- MACROS & CONSTANTS --------------------------------------------------- */ @@ -115,18 +117,26 @@ int main( int argc, char ** argv ) uint16_t rssi_cumu; float rssi_thresh[] = {0.1,0.3,0.5,0.8,1}; + /* Parameter parsing */ + int option_index = 0; + static struct option long_options[] = { + {"path", 1, 0, 0}, + {0, 0, 0, 0} + }; + /* Parse command line options */ - while((i = getopt(argc, argv, "hf:n:b:l:o:")) != -1) { + while ((i = getopt_long (argc, argv, "hf:n:b:l:o:p:", long_options, &option_index)) != -1) { switch (i) { case 'h': - printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); - printf(" -f <float>:<float>:<float> Frequency vector to scan in MHz (start:step:stop)\n"); - printf(" start>%3.3f step>%1.3f stop<%3.3f\n", MIN_FREQ/1e6, MIN_STEP_FREQ/1e6, MAX_FREQ/1e6); - printf(" -b <uint> Channel bandwidth in KHz [25,50,100,125,200,250,500]\n"); - printf(" -n <uint> Total number of RSSI points [1..65535]\n"); - printf(" -o <int> Offset in dB to be applied to the SX127x RSSI [-128..127]\n"); - printf(" -l <char> Log file name\n"); - printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); + printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); + printf(" -f <float>:<float>:<float> Frequency vector to scan in MHz (start:step:stop)\n"); + printf(" start>%3.3f step>%1.3f stop<%3.3f\n", MIN_FREQ/1e6, MIN_STEP_FREQ/1e6, MAX_FREQ/1e6); + printf(" -b <uint> Channel bandwidth in KHz [25,50,100,125,200,250,500]\n"); + printf(" -n <uint> Total number of RSSI points [1..65535]\n"); + printf(" -o <int> Offset in dB to be applied to the SX127x RSSI [-128..127]\n"); + printf(" -l <string> Log file name\n"); + printf(" --path <string> path of SPIDEV e.g. /dev/spidev0.0\n"); + printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); return EXIT_SUCCESS; case 'f': /* -f <float>:<float>:<float> Frequency vector to scan in MHz, start:step:stop */ @@ -206,6 +216,22 @@ int main( int argc, char ** argv ) } break; + case 0: + if (strcmp(long_options[option_index].name,"path") == 0) { + i = sscanf(optarg, "%s", arg_s); + if ((i != 1) || (strncmp(arg_s, "/dev/", 5 ) != 0)) { + printf("ERROR: argument parsing of --path argument. Use -h to print help\n"); + return EXIT_FAILURE; + } + else { + lgw_spi_set_path(arg_s); + } + } else { + printf("ERROR: argument parsing options. Use -h to print help\n"); + return EXIT_FAILURE; + } + break; + default: printf("ERROR: argument parsing options. -h for help.\n"); return EXIT_FAILURE; |