From 116d2f6402a83c824b0226c42fb08a22c75038b2 Mon Sep 17 00:00:00 2001 From: Harsh Sharma Date: Fri, 24 Jan 2020 13:22:57 -0600 Subject: Bug fix for util tx continuous's attn setting and added spi path option for util tx test --- util_tx_continuous/src/util_tx_continuous.c | 4 ++-- util_tx_test/src/util_tx_test.c | 22 +++++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/util_tx_continuous/src/util_tx_continuous.c b/util_tx_continuous/src/util_tx_continuous.c index b8b59e9..591054a 100644 --- a/util_tx_continuous/src/util_tx_continuous.c +++ b/util_tx_continuous/src/util_tx_continuous.c @@ -150,7 +150,7 @@ int main(int argc, char **argv) printf(" --br FSK bitrate in kbps, [0.5:250]\n"); printf(" --fdev FSK frequency deviation in kHz, [1:250]\n"); printf(" --bt FSK gaussian filter BT trim, [0:3]\n"); - printf(" --attn Attenuator value in dB, required LGA module or MTAC full card\n"); + printf(" --attn Attenuator value in dB, required LGA module or MTAC full card\n"); printf(" --path Path of SPIDEV e.g. /dev/spidev0.0\n"); printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); return EXIT_SUCCESS; @@ -270,7 +270,7 @@ int main(int argc, char **argv) } else if (strcmp(long_options[option_index].name,"attn") == 0) { i = sscanf(optarg, "%u", &arg_u); - if ((i != 1) || (arg_f > 127) ) { + if ((i != 1) || (arg_u > 127) ) { printf("ERROR: argument parsing of --attn argument. Use -h to print help\n"); return EXIT_FAILURE; } diff --git a/util_tx_test/src/util_tx_test.c b/util_tx_test/src/util_tx_test.c index 74c163f..0ac8244 100644 --- a/util_tx_test/src/util_tx_test.c +++ b/util_tx_test/src/util_tx_test.c @@ -37,6 +37,7 @@ Maintainer: Sylvain Miermont #include "loragw_hal.h" #include "loragw_reg.h" #include "loragw_aux.h" +#include "loragw_spi.h" /* -------------------------------------------------------------------------- */ /* --- PRIVATE MACROS ------------------------------------------------------- */ @@ -147,11 +148,12 @@ void usage(void) { printf(" -i send packet using inverted modulation polarity\n"); printf(" -t pause between packets (ms)\n"); printf(" -x nb of times the sequence is repeated (-1 loop until stopped)\n"); - printf(" --lbt-freq lbt first channel frequency in MHz\n"); - printf(" --lbt-nbch lbt number of channels [1..8]\n"); - printf(" --lbt-sctm lbt scan time in usec to be applied to all channels [128, 5000]\n"); - printf(" --lbt-rssi lbt rssi target in dBm [-128..0]\n"); - printf(" --lbt-rssi-offset rssi offset in dB to be applied to SX127x RSSI [-128..127]\n"); + printf(" --lbt-freq lbt first channel frequency in MHz\n"); + printf(" --lbt-nbch lbt number of channels [1..8]\n"); + printf(" --lbt-sctm lbt scan time in usec to be applied to all channels [128, 5000]\n"); + printf(" --lbt-rssi lbt rssi target in dBm [-128..0]\n"); + printf(" --lbt-rssi-offset rssi offset in dB to be applied to SX127x RSSI [-128..127]\n"); + printf(" --path path of SPIDEV e.g. /dev/spidev0.0\n"); } /* -------------------------------------------------------------------------- */ @@ -213,6 +215,7 @@ int main(int argc, char **argv) {"lbt-rssi", required_argument, 0, 0}, {"lbt-nbch", required_argument, 0, 0}, {"lbt-rssi-offset", required_argument, 0, 0}, + {"path", required_argument, 0, 0}, {0, 0, 0, 0} }; @@ -469,6 +472,15 @@ int main(int argc, char **argv) usage(); return EXIT_FAILURE; } + } else if (strcmp(long_options[option_index].name,"path") == 0) { /* Path to spi device */ + 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; default: -- cgit v1.2.3