diff options
author | Harsh Sharma <harsh.sharma@multitech.com> | 2020-01-24 13:57:31 -0600 |
---|---|---|
committer | Harsh Sharma <harsh.sharma@multitech.com> | 2020-01-24 13:57:31 -0600 |
commit | d14d5e0766f7190cd3f6d91003e8d3f356f91359 (patch) | |
tree | c8fabcf32a444a46d41d71f2088f46d2722754f9 /util_lbt_test | |
parent | 116d2f6402a83c824b0226c42fb08a22c75038b2 (diff) | |
download | lora_gateway_mtac_full-d14d5e0766f7190cd3f6d91003e8d3f356f91359.tar.gz lora_gateway_mtac_full-d14d5e0766f7190cd3f6d91003e8d3f356f91359.tar.bz2 lora_gateway_mtac_full-d14d5e0766f7190cd3f6d91003e8d3f356f91359.zip |
Added spi path to util lbt test
Diffstat (limited to 'util_lbt_test')
-rw-r--r-- | util_lbt_test/src/util_lbt_test.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/util_lbt_test/src/util_lbt_test.c b/util_lbt_test/src/util_lbt_test.c index 1c8b185..16af7ac 100644 --- a/util_lbt_test/src/util_lbt_test.c +++ b/util_lbt_test/src/util_lbt_test.c @@ -31,12 +31,14 @@ Maintainer: Michael Coracin #include <signal.h> /* sigaction */ #include <unistd.h> /* getopt access */ #include <stdlib.h> /* rand */ +#include <string.h> /* strncmp */ #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 ------------------------------------------- */ @@ -76,10 +78,11 @@ static void sig_handler(int sigio) { 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(" -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(" -p <string> path of SPIDEV e.g. /dev/spidev0.0\n"); } /* -------------------------------------------------------------------------- */ @@ -89,7 +92,7 @@ int main(int argc, char **argv) { int i; int xi = 0; - + char arg_s[64]; /* in/out variables */ double f1 = 0.0; uint32_t f_init = 0; /* in Hz */ @@ -105,7 +108,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 (argc, argv, "h:f:s:r:o:p:")) != -1) { switch (i) { case 'h': usage(); @@ -142,6 +145,16 @@ int main(int argc, char **argv) rssi_target_dBm = xi; } break; + case 'p': + 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); + } + break; case 'o': /* -o <int> SX127x RSSI offset [-128..127] */ i = sscanf(optarg, "%i", &xi); if((i != 1) || (xi < -128) || (xi > 127)) { |