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_lbt_test/src/util_lbt_test.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_lbt_test/src/util_lbt_test.c')
-rw-r--r-- | util_lbt_test/src/util_lbt_test.c | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/util_lbt_test/src/util_lbt_test.c b/util_lbt_test/src/util_lbt_test.c index 1c8b185..f143a92 100644 --- a/util_lbt_test/src/util_lbt_test.c +++ b/util_lbt_test/src/util_lbt_test.c @@ -31,12 +31,15 @@ Maintainer: Michael Coracin #include <signal.h> /* sigaction */ #include <unistd.h> /* getopt access */ #include <stdlib.h> /* rand */ +#include <string.h> /* strncmp */ +#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" /* -------------------------------------------------------------------------- */ /* --- PRIVATE MACROS & CONSTANTS ------------------------------------------- */ @@ -75,11 +78,12 @@ static void sig_handler(int sigio) { /* describe command line options */ void usage(void) { printf("Available options:\n"); - printf(" -h print this help\n"); - printf(" -f <float> frequency in MHz of the first LBT channel\n"); - printf(" -o <int> offset in dB to be applied to the SX127x RSSI [-128..127]\n"); - printf(" -r <int> target RSSI: signal strength target used to detect if the channel is clear or not [-128..0]\n"); - printf(" -s <uint> scan time in µs for all 8 LBT channels [128,5000]\n"); + printf(" -h print this help\n"); + printf(" -f <float> frequency in MHz of the first LBT channel\n"); + printf(" -o <int> offset in dB to be applied to the SX127x RSSI [-128..127]\n"); + printf(" -r <int> target RSSI: signal strength target used to detect if the channel is clear or not [-128..0]\n"); + printf(" -s <uint> scan time in µs for all 8 LBT channels [128,5000]\n"); + printf(" --path <string> path of SPIDEV e.g. /dev/spidev0.0\n"); } /* -------------------------------------------------------------------------- */ @@ -89,7 +93,12 @@ int main(int argc, char **argv) { int i; int xi = 0; - + int option_index = 0; + static struct option long_options[] = { + {"path", 1, 0, 0}, + {0, 0, 0, 0} + }; + char arg_s[64]; /* in/out variables */ double f1 = 0.0; uint32_t f_init = 0; /* in Hz */ @@ -105,7 +114,7 @@ int main(int argc, char **argv) uint32_t freq_offset; /* parse command line options */ - while ((i = getopt (argc, argv, "h:f:s:r:o:")) != -1) { + while ((i = getopt_long (argc, argv, "h:f:s:r:o:", long_options, &option_index)) != -1) { switch (i) { case 'h': usage(); @@ -152,6 +161,22 @@ int main(int argc, char **argv) rssi_offset = (int8_t)xi; } 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: MSG("ERROR: argument parsing use -h option for help\n"); usage(); |