From d14d5e0766f7190cd3f6d91003e8d3f356f91359 Mon Sep 17 00:00:00 2001 From: Harsh Sharma Date: Fri, 24 Jan 2020 13:57:31 -0600 Subject: Added spi path to util lbt test --- util_lbt_test/src/util_lbt_test.c | 25 +++++++++++++++++++------ 1 file 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 /* sigaction */ #include /* getopt access */ #include /* rand */ +#include /* 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 frequency in MHz of the first LBT channel\n"); - printf(" -o offset in dB to be applied to the SX127x RSSI [-128..127]\n"); - printf(" -r target RSSI: signal strength target used to detect if the channel is clear or not [-128..0]\n"); - printf(" -s scan time in µs for all 8 LBT channels [128,5000]\n"); + printf(" -f frequency in MHz of the first LBT channel\n"); + printf(" -o offset in dB to be applied to the SX127x RSSI [-128..127]\n"); + printf(" -r target RSSI: signal strength target used to detect if the channel is clear or not [-128..0]\n"); + printf(" -s scan time in µs for all 8 LBT channels [128,5000]\n"); + printf(" -p 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 SX127x RSSI offset [-128..127] */ i = sscanf(optarg, "%i", &xi); if((i != 1) || (xi < -128) || (xi > 127)) { -- cgit v1.2.3