summaryrefslogtreecommitdiff
path: root/util_spi_stress
diff options
context:
space:
mode:
authorHarsh Sharma <harsh.sharma@multitech.com>2020-01-02 13:57:50 -0600
committerHarsh Sharma <harsh.sharma@multitech.com>2020-01-02 13:57:50 -0600
commita0a94c3336574482d16fa910e94d7f07bba60123 (patch)
tree09605db3875b98d0df0d1eb5d1ad3c850dd95d7d /util_spi_stress
parent583ef0e2aa87d5e0c7ca71b3a681c801ff7b952a (diff)
downloadlora_gateway_mtac_full-a0a94c3336574482d16fa910e94d7f07bba60123.tar.gz
lora_gateway_mtac_full-a0a94c3336574482d16fa910e94d7f07bba60123.tar.bz2
lora_gateway_mtac_full-a0a94c3336574482d16fa910e94d7f07bba60123.zip
Added spidev to the commandline options for the util_spi_stress5.0.1-mts-3
Diffstat (limited to 'util_spi_stress')
-rw-r--r--util_spi_stress/src/util_spi_stress.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/util_spi_stress/src/util_spi_stress.c b/util_spi_stress/src/util_spi_stress.c
index 6cc5f04..c33f18f 100644
--- a/util_spi_stress/src/util_spi_stress.c
+++ b/util_spi_stress/src/util_spi_stress.c
@@ -31,6 +31,7 @@ Maintainer: Sylvain Miermont
#include <signal.h> /* sigaction */
#include <unistd.h> /* getopt access */
#include <stdlib.h> /* rand */
+#include <getopt.h> /* getopt_long */
#include "loragw_reg.h"
@@ -77,8 +78,9 @@ static void sig_handler(int sigio) {
/* describe command line options */
void usage(void) {
MSG( "Available options:\n");
- MSG( " -h print this help\n");
- MSG( " -t <int> specify which test you want to run (1-4)\n");
+ MSG( " -h Print this help\n");
+ MSG( " -t <uint> Specify which test you want to run (1-4)\n");
+ MSG( " --path <string> Path of SPIDEV e.g. /dev/spidev0.0\n");
}
/* -------------------------------------------------------------------------- */
@@ -105,8 +107,15 @@ int main(int argc, char **argv)
uint8_t test_buff[BUFF_SIZE];
uint8_t read_buff[BUFF_SIZE];
+ 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, "ht:")) != -1) {
+ while ((i = getopt_long (argc, argv, "ht:", long_options, &option_index)) != -1) {
switch (i) {
case 'h':
usage();
@@ -123,6 +132,24 @@ int main(int argc, char **argv)
}
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 {
+ MSG("ERROR: argument parsing use -h option for help\n");
+ usage();
+ return EXIT_FAILURE;
+ }
+ break;
+
default:
MSG("ERROR: argument parsing use -h option for help\n");
usage();
@@ -142,7 +169,7 @@ int main(int argc, char **argv)
/* start SPI link */
i = lgw_connect(false, DEFAULT_TX_NOTCH_FREQ);
if (i != LGW_REG_SUCCESS) {
- MSG("ERROR: lgw_connect() did not return SUCCESS");
+ MSG("ERROR: Unable to connect to the concentrator\n");
return EXIT_FAILURE;
}
@@ -160,7 +187,7 @@ int main(int argc, char **argv)
}
}
if (error) {
- printf("error during the %ith iteration: write 0x%02X, read 0x%02X\n", i+1, test_value, read_value);
+ printf("Error during the %ith iteration: write 0x%02X, read 0x%02X\n", i+1, test_value, read_value);
printf("Repeat read of target register:");
for (i=0; i<READS_WHEN_ERROR; ++i) {
lgw_reg_r(LGW_IMPLICIT_PAYLOAD_LENGHT, &read_value);