diff options
author | Harsh Sharma <harsh.sharma@multitech.com> | 2020-02-03 15:14:42 -0600 |
---|---|---|
committer | Harsh Sharma <harsh.sharma@multitech.com> | 2020-02-03 15:14:42 -0600 |
commit | febb8372c248a11007eee7ea0267178f0dec61ee (patch) | |
tree | a06efdd251bd29513b23954f44c4d15d8c6bbddc /libloragw/tst | |
parent | ac8d94851bb1a0bb22cd9815a483e8ed2a99e8f5 (diff) | |
download | lora_gateway_mtac_full-febb8372c248a11007eee7ea0267178f0dec61ee.tar.gz lora_gateway_mtac_full-febb8372c248a11007eee7ea0267178f0dec61ee.tar.bz2 lora_gateway_mtac_full-febb8372c248a11007eee7ea0267178f0dec61ee.zip |
Added spi path option to test loragw hal
Diffstat (limited to 'libloragw/tst')
-rw-r--r-- | libloragw/tst/test_loragw_hal.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/libloragw/tst/test_loragw_hal.c b/libloragw/tst/test_loragw_hal.c index e2fee5e..3bdd7b2 100644 --- a/libloragw/tst/test_loragw_hal.c +++ b/libloragw/tst/test_loragw_hal.c @@ -30,7 +30,9 @@ Maintainer: Sylvain Miermont #include <string.h> /* memset */ #include <signal.h> /* sigaction */ #include <unistd.h> /* getopt access */ +#include <getopt.h> /* getopt_long */ +#include "loragw_spi.h" #include "loragw_hal.h" #include "loragw_reg.h" #include "loragw_aux.h" @@ -78,6 +80,7 @@ void usage(void) { printf( " -t <float> Radio TX frequency in MHz\n"); printf( " -r <int> Radio type (SX1255:1255, SX1257:1257)\n"); printf( " -k <int> Concentrator clock source (0: radio_A, 1: radio_B(default))\n"); + printf(" --path <string> path of SPIDEV e.g. /dev/spidev0.0\n"); } /* -------------------------------------------------------------------------- */ @@ -107,8 +110,16 @@ int main(int argc, char **argv) double xd = 0.0; int xi = 0; + /* Parameter parsing */ + int option_index = 0; + static struct option long_options[] = { + {"path", 1, 0, 0}, + {0, 0, 0, 0} + }; + char arg_s[64]; + /* parse command line options */ - while ((i = getopt (argc, argv, "ha:b:t:r:k:")) != -1) { + while ((i = getopt_long (argc, argv, "ha:b:r:n:k:t:", long_options, &option_index)) != -1) { switch (i) { case 'h': usage(); @@ -145,6 +156,22 @@ int main(int argc, char **argv) sscanf(optarg, "%i", &xi); clocksource = (uint8_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 -1; + } + else { + lgw_spi_set_path(arg_s); + } + } + else { + printf("ERROR: argument parsing options. Use -h to print help\n"); + return -1; + } + break; default: printf("ERROR: argument parsing\n"); usage(); @@ -307,7 +334,7 @@ int main(int argc, char **argv) if (i == LGW_HAL_SUCCESS) { printf("*** Concentrator started ***\n"); } else { - printf("*** Impossible to start concentrator ***\n"); + printf("*** Unable to start concentrator ***\n"); return -1; } |