From dc09db37114c702cacef4f70abc1b1526ce95334 Mon Sep 17 00:00:00 2001 From: Harsh Sharma Date: Mon, 24 Oct 2022 17:33:23 -0500 Subject: Fixed incorrect clock sources and added spi path option to test gps --- libloragw/tst/test_loragw_gps.c | 42 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'libloragw/tst/test_loragw_gps.c') diff --git a/libloragw/tst/test_loragw_gps.c b/libloragw/tst/test_loragw_gps.c index 6efd351..c535878 100644 --- a/libloragw/tst/test_loragw_gps.c +++ b/libloragw/tst/test_loragw_gps.c @@ -33,6 +33,7 @@ Maintainer: Michael Coracin #include /* read */ #include "loragw_hal.h" +#include "loragw_spi.h" #include "loragw_gps.h" #include "loragw_aux.h" @@ -54,6 +55,14 @@ static void gps_process_coords(void); /* -------------------------------------------------------------------------- */ /* --- PRIVATE FUNCTIONS DEFINITION ----------------------------------------- */ + +void usage(void) { + //printf("Library version information: %s\n", lgw_version_info()); + printf("Available options:\n"); + printf(" -h print this help\n"); + printf(" -d COM path to be used to connect the concentrator\n"); +} + static void sig_handler(int sigio) { if (sigio == SIGQUIT) { quit_sig = 1;; @@ -131,11 +140,12 @@ static void gps_process_coords(void) { /* -------------------------------------------------------------------------- */ /* --- MAIN FUNCTION -------------------------------------------------------- */ -int main() +int main(int argc, char **argv) { struct sigaction sigact; /* SIGQUIT&SIGINT&SIGTERM signal handling */ int i; + unsigned int arg_u; /* concentrator variables */ struct lgw_conf_board_s boardconf; @@ -148,6 +158,34 @@ int main() /* NMEA/UBX variables */ enum gps_msg latest_msg; /* keep track of latest NMEA/UBX message parsed */ + char arg_s[64]; + + /* parse command line options */ + while ((i = getopt (argc, argv, "hd:")) != -1) { + switch (i) { + case 'h': + usage(); + return -1; + break; + case 'd': + if (optarg != NULL) { + 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); + } + } + break; + default: + printf("ERROR: argument parsing\n"); + usage(); + exit(EXIT_FAILURE); + } + } + /* configure signal handling */ sigemptyset(&sigact.sa_mask); @@ -172,7 +210,7 @@ int main() /* board config */ memset(&boardconf, 0, sizeof(boardconf)); boardconf.lorawan_public = true; - boardconf.clksrc = 1; + boardconf.clksrc = 0; lgw_board_setconf(boardconf); /* RF config */ -- cgit v1.2.3