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_cal.c | 2 +- libloragw/tst/test_loragw_gps.c | 42 +++++++++++++++++++++++++++++++++++++++-- libloragw/tst/test_loragw_hal.c | 2 +- util_tx_test/src/util_tx_test.c | 2 +- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/libloragw/tst/test_loragw_cal.c b/libloragw/tst/test_loragw_cal.c index 60c5ce7..8b223e4 100644 --- a/libloragw/tst/test_loragw_cal.c +++ b/libloragw/tst/test_loragw_cal.c @@ -140,7 +140,7 @@ int main(int argc, char **argv) double xd = 0.0; uint32_t fa = 0, fb = 0; enum lgw_radio_type_e radio_type = LGW_RADIO_TYPE_NONE; - uint8_t clocksource = 1; /* Radio B is source by default */ + uint8_t clocksource = 0; /* Radio B is source by default */ uint8_t tx_enable = 0; int nb_cal = 5; 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 */ diff --git a/libloragw/tst/test_loragw_hal.c b/libloragw/tst/test_loragw_hal.c index 37e8b42..16af817 100644 --- a/libloragw/tst/test_loragw_hal.c +++ b/libloragw/tst/test_loragw_hal.c @@ -102,7 +102,7 @@ int main(int argc, char **argv) int nb_pkt; uint32_t fa = 0, fb = 0, ft = 0; enum lgw_radio_type_e radio_type = LGW_RADIO_TYPE_NONE; - uint8_t clocksource = 1; /* Radio B is source by default */ + uint8_t clocksource = 0; /* Radio B is source by default */ uint32_t tx_cnt = 0; unsigned long loop_cnt = 0; diff --git a/util_tx_test/src/util_tx_test.c b/util_tx_test/src/util_tx_test.c index 90d7dec..186b1d2 100644 --- a/util_tx_test/src/util_tx_test.c +++ b/util_tx_test/src/util_tx_test.c @@ -205,7 +205,7 @@ int main(int argc, char **argv) /* RF configuration (TX fail if RF chain is not enabled) */ enum lgw_radio_type_e radio_type = LGW_RADIO_TYPE_NONE; - uint8_t clocksource = 1; /* Radio B is source by default */ + uint8_t clocksource = 0; /* Radio B is source by default */ struct lgw_conf_board_s boardconf; struct lgw_conf_lbt_s lbtconf; struct lgw_conf_rxrf_s rfconf; -- cgit v1.2.3