summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarsh Sharma <harsh.sharma@multitech.com>2020-02-03 15:06:52 -0600
committerHarsh Sharma <harsh.sharma@multitech.com>2020-02-03 15:06:52 -0600
commitac8d94851bb1a0bb22cd9815a483e8ed2a99e8f5 (patch)
tree4833078d0475c9b2b16052a5fa5d641dc739b9f8
parent9eb0233d94d05b89d8dab1ad192f5010d1282341 (diff)
downloadlora_gateway_mtac_full-ac8d94851bb1a0bb22cd9815a483e8ed2a99e8f5.tar.gz
lora_gateway_mtac_full-ac8d94851bb1a0bb22cd9815a483e8ed2a99e8f5.tar.bz2
lora_gateway_mtac_full-ac8d94851bb1a0bb22cd9815a483e8ed2a99e8f5.zip
Added spi path option to test_loragw_cal
-rw-r--r--libloragw/tst/test_loragw_cal.c44
1 files changed, 35 insertions, 9 deletions
diff --git a/libloragw/tst/test_loragw_cal.c b/libloragw/tst/test_loragw_cal.c
index 533d189..60c5ce7 100644
--- a/libloragw/tst/test_loragw_cal.c
+++ b/libloragw/tst/test_loragw_cal.c
@@ -31,12 +31,13 @@ Maintainer: Sylvain Miermont
#include <signal.h> /* sigaction */
#include <math.h> /* cos */
#include <unistd.h> /* getopt access */
+#include <getopt.h> /* getopt_long */
#include "loragw_hal.h"
#include "loragw_reg.h"
#include "loragw_aux.h"
#include "loragw_radio.h"
-
+#include "loragw_spi.h"
/* -------------------------------------------------------------------------- */
/* --- PRIVATE MACROS ------------------------------------------------------- */
@@ -99,13 +100,14 @@ void usage (void);
void usage(void) {
printf("Library version information: %s\n", lgw_version_info());
printf( "Available options:\n");
- printf( " -h print this help\n");
- printf( " -a <float> Radio A frequency in MHz\n");
- printf( " -b <float> Radio B frequency in MHz\n");
- printf( " -r <int> Radio type (SX1255:1255, SX1257:1257)\n");
- printf( " -n <uint> Number of calibration iterations\n");
- printf( " -k <int> Concentrator clock source (0:radio_A, 1:radio_B(default))\n");
- printf( " -t <int> Radio to run TX calibration on (0:None(default), 1:radio_A, 2:radio_B, 3:both)\n");
+ printf( " -h print this help\n");
+ printf( " -a <float> Radio A frequency in MHz\n");
+ printf( " -b <float> Radio B frequency in MHz\n");
+ printf( " -r <int> Radio type (SX1255:1255, SX1257:1257)\n");
+ printf( " -n <uint> Number of calibration iterations\n");
+ printf( " -k <int> Concentrator clock source (0:radio_A, 1:radio_B(default))\n");
+ printf( " -t <int> Radio to run TX calibration on (0:None(default), 1:radio_A, 2:radio_B, 3:both)\n");
+ printf(" --path <string> path of SPIDEV e.g. /dev/spidev0.0\n");
}
/* -------------------------------------------------------------------------- */
@@ -142,8 +144,16 @@ int main(int argc, char **argv)
uint8_t tx_enable = 0;
int nb_cal = 5;
+ /* 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:r:n:k:t:")) != -1) {
+ while ((i = getopt_long (argc, argv, "ha:b:r:n:k:t:", long_options, &option_index)) != -1) {
switch (i) {
case 'h':
usage();
@@ -190,6 +200,22 @@ int main(int argc, char **argv)
sscanf(optarg, "%i", &xi);
tx_enable = (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();