Mercurial > ublox > ublox8
changeset 46:0f758661d962
capture: add a verbose mode to ease debugging
In the verbose mode, hexdump all received ubx messages to standard error.
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Thu, 16 Jan 2020 12:25:35 -0500 |
parents | d71fc34c755d |
children | 359e7e8ef8d8 |
files | capture.c iothread.c iothread.h |
diffstat | 3 files changed, 16 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/capture.c Thu Jan 16 11:39:17 2020 -0500 +++ b/capture.c Thu Jan 16 12:25:35 2020 -0500 @@ -47,6 +47,7 @@ fprintf(stderr, " -u <ubxport> port number (default %d; 0=DCC, " "1=UART, 3=USB, 4=SPI)\n", DEFAULT_UBXPORT); fprintf(stderr, " -l <log> path for framed UBX message log\n"); + fprintf(stderr, " -v verbose\n"); exit(1); } @@ -209,6 +210,7 @@ bool enable_glonass; bool enable_sbas; uint8_t ubxport; + bool verbose; FILE *ifile; FILE *rfile; int opt; @@ -223,8 +225,9 @@ enable_glonass = false; enable_sbas = false; ubxport = DEFAULT_UBXPORT; + verbose = false; - while ((opt = getopt(argc, argv, "+cegrsd:l:u:")) != -1) { + while ((opt = getopt(argc, argv, "+cegrsd:l:u:v")) != -1) { switch (opt) { case 'c': enable_beidou = true; @@ -262,6 +265,9 @@ usage(argv[0]); } break; + case 'v': + verbose = true; + break; default: usage(argv[0]); } @@ -361,7 +367,7 @@ return 10; } - ret = iothread_start(ifile, rfile); + ret = iothread_start(ifile, rfile, verbose); if (ret) { fprintf(stderr, "Error: Failed to spawn I/O thread: %s\n", xstrerror(ret));
--- a/iothread.c Thu Jan 16 11:39:17 2020 -0500 +++ b/iothread.c Thu Jan 16 12:25:35 2020 -0500 @@ -38,6 +38,7 @@ static pthread_t io_thread; static FILE *input_file; static FILE *log_file; +static bool verbose; /* read until we get the beginning of a NMEA or UBX message */ static int sync_reader(void) @@ -145,8 +146,9 @@ if (ret) return ret; - { + if (verbose) { char out[sizeof(raw)*2+1]; + hexdumpz(out, raw, hdr.len, false); fprintf(stderr, "< %02x%02x %02x %02x (%s) %04x %s %02x%02x\n", hdr.sync[0], hdr.sync[1], @@ -236,10 +238,11 @@ return NULL; } -int iothread_start(FILE *ifile, FILE *lfile) +int iothread_start(FILE *ifile, FILE *lfile, bool _verbose) { input_file = ifile; log_file = lfile; + verbose = _verbose; return xthr_create(&io_thread, iothread_reader, NULL); }