summaryrefslogtreecommitdiff
path: root/libloragw/tst/test_loragw_gps.c
diff options
context:
space:
mode:
Diffstat (limited to 'libloragw/tst/test_loragw_gps.c')
-rw-r--r--libloragw/tst/test_loragw_gps.c42
1 files changed, 40 insertions, 2 deletions
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 <unistd.h> /* 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 <path> 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 */