From c08bf1d60c88179d791678a2db6db61f87fea032 Mon Sep 17 00:00:00 2001 From: Harsh Sharma Date: Fri, 24 Jan 2020 15:31:21 -0600 Subject: Added spi device option to util spectral scan --- util_spectral_scan/src/util_spectral_scan.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/util_spectral_scan/src/util_spectral_scan.c b/util_spectral_scan/src/util_spectral_scan.c index cbc8377..91a358f 100644 --- a/util_spectral_scan/src/util_spectral_scan.c +++ b/util_spectral_scan/src/util_spectral_scan.c @@ -37,6 +37,7 @@ Maintainer: Michael Coracin #include "loragw_hal.h" #include "loragw_radio.h" #include "loragw_fpga.h" +#include "loragw_spi.h" /* -------------------------------------------------------------------------- */ /* --- MACROS & CONSTANTS --------------------------------------------------- */ @@ -116,7 +117,7 @@ int main( int argc, char ** argv ) float rssi_thresh[] = {0.1,0.3,0.5,0.8,1}; /* Parse command line options */ - while((i = getopt(argc, argv, "hf:n:b:l:o:")) != -1) { + while((i = getopt(argc, argv, "hf:n:b:l:o:p:")) != -1) { switch (i) { case 'h': printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); @@ -126,6 +127,7 @@ int main( int argc, char ** argv ) printf(" -n Total number of RSSI points [1..65535]\n"); printf(" -o Offset in dB to be applied to the SX127x RSSI [-128..127]\n"); printf(" -l Log file name\n"); + printf(" -p path of SPIDEV e.g. /dev/spidev0.0\n"); printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); return EXIT_SUCCESS; @@ -206,6 +208,16 @@ int main( int argc, char ** argv ) } break; + case 'p': /* -p Path for spi device */ + j = sscanf(optarg, "%s", arg_s); + if (j != 1) { + printf("ERROR: argument parsing of -p argument. -h for help.\n"); + return EXIT_FAILURE; + } else { + lgw_spi_set_path(arg_s); + } + break; + default: printf("ERROR: argument parsing options. -h for help.\n"); return EXIT_FAILURE; -- cgit v1.2.3