diff options
-rw-r--r-- | driver_ais.c | 30 | ||||
-rw-r--r-- | driver_garmin.c | 14 | ||||
-rw-r--r-- | drivers.c | 13 | ||||
-rw-r--r-- | gpsd.h-tail | 2 | ||||
-rw-r--r-- | isgps.c | 2 | ||||
-rw-r--r-- | net_ntrip.c | 77 | ||||
-rw-r--r-- | subframe.c | 8 |
7 files changed, 74 insertions, 72 deletions
diff --git a/driver_ais.c b/driver_ais.c index 9b5065ab..675955d2 100644 --- a/driver_ais.c +++ b/driver_ais.c @@ -59,7 +59,7 @@ static void from_sixbit(unsigned char *bitvec, uint start, int count, char *to) } /*@ +charint @*/ -bool ais_binary_decode(const int debug, +bool ais_binary_decode(const struct errout_t *errout, struct ais_t *ais, const unsigned char *bits, size_t bitlen, struct ais_type24_queue_t *type24_queue) @@ -78,24 +78,24 @@ bool ais_binary_decode(const int debug, ais->type = UBITS(0, 6); ais->repeat = UBITS(6, 2); ais->mmsi = UBITS(8, 30); - gpsd_report(debug, LOG_INF, + gpsd_notify(errout, LOG_INF, "AIVDM message type %d, MMSI %09d:\n", ais->type, ais->mmsi); #define PERMISSIVE_LENGTH_CHECK(correct) \ if (bitlen < correct) { \ - gpsd_report(debug, LOG_ERROR, \ + gpsd_notify(errout, LOG_ERROR, \ "AIVDM message type %d size < %d bits (%zd).\n", \ ais->type, correct, bitlen); \ return false; \ } else if (bitlen > correct) { \ - gpsd_report(debug, LOG_WARN, \ + gpsd_notify(errout, LOG_WARN, \ "AIVDM message type %d size > %d bits (%zd).\n", \ ais->type, correct, bitlen); \ } #define RANGE_CHECK(min, max) \ if (bitlen < min || bitlen > max) { \ - gpsd_report(debug, LOG_ERROR, \ + gpsd_notify(errout, LOG_ERROR, \ "AIVDM message type %d size is out of range (%zd).\n", \ ais->type, bitlen); \ return false; \ @@ -145,7 +145,7 @@ bool ais_binary_decode(const int debug, break; case 5: /* Ship static and voyage related data */ if (bitlen != 424) { - gpsd_report(debug, LOG_WARN, + gpsd_notify(errout, LOG_WARN, "AIVDM message type 5 size not 424 bits (%zd).\n", bitlen); /* @@ -944,7 +944,7 @@ bool ais_binary_decode(const int debug, { struct ais_type24a_t *saveptr = &type24_queue->ships[type24_queue->index]; - gpsd_report(debug, LOG_PROG, + gpsd_notify(errout, LOG_PROG, "AIVDM: 24A from %09u stashed.\n", ais->mmsi); saveptr->mmsi = ais->mmsi; @@ -991,7 +991,7 @@ bool ais_binary_decode(const int debug, (void)strlcpy(ais->type24.shipname, type24_queue->ships[i].shipname, sizeof(type24_queue->ships[i].shipname)); - gpsd_report(debug, LOG_PROG, + gpsd_notify(errout, LOG_PROG, "AIVDM 24B from %09u matches a 24A.\n", ais->mmsi); /* prevent false match if a 24B is repeated */ @@ -1005,7 +1005,7 @@ bool ais_binary_decode(const int debug, ais->type24.part = part_b; return true; default: - gpsd_report(debug, LOG_WARN, + gpsd_notify(errout, LOG_WARN, "AIVDM message type 24 of subtype unknown.\n"); return false; } @@ -1013,7 +1013,7 @@ bool ais_binary_decode(const int debug, case 25: /* Binary Message, Single Slot */ /* this check and the following one reject line noise */ if (bitlen < 40 || bitlen > 168) { - gpsd_report(debug, LOG_WARN, + gpsd_notify(errout, LOG_WARN, "AIVDM message type 25 size not between 40 to 168 bits (%zd).\n", bitlen); return false; @@ -1021,7 +1021,7 @@ bool ais_binary_decode(const int debug, ais->type25.addressed = (bool)UBITS(38, 1); ais->type25.structured = (bool)UBITS(39, 1); if (bitlen < (unsigned)(40 + (16*ais->type25.structured) + (30*ais->type25.addressed))) { - gpsd_report(debug, LOG_WARN, + gpsd_notify(errout, LOG_WARN, "AIVDM message type 25 too short for mode.\n"); return false; } @@ -1049,7 +1049,7 @@ bool ais_binary_decode(const int debug, ais->type26.addressed = (bool)UBITS(38, 1); ais->type26.structured = (bool)UBITS(39, 1); if ((signed)bitlen < 40 + 16*ais->type26.structured + 30*ais->type26.addressed + 20) { - gpsd_report(debug, LOG_WARN, + gpsd_notify(errout, LOG_WARN, "AIVDM message type 26 too short for mode.\n"); return false; } @@ -1064,7 +1064,7 @@ bool ais_binary_decode(const int debug, break; case 27: /* Long Range AIS Broadcast message */ if (bitlen != 96 && bitlen != 168) { - gpsd_report(debug, LOG_WARN, + gpsd_notify(errout, LOG_WARN, "unexpected AIVDM message type 27 (%zd).\n", bitlen); return false; @@ -1073,7 +1073,7 @@ bool ais_binary_decode(const int debug, * This is an implementation error observed in the wild, * sending a full 168-bit slot rather than just 96 bits. */ - gpsd_report(debug, LOG_WARN, + gpsd_notify(errout, LOG_WARN, "oversized 169=8-bit AIVDM message type 27.\n"); } ais->type27.accuracy = (bool)UBITS(38, 1); @@ -1086,7 +1086,7 @@ bool ais_binary_decode(const int debug, ais->type27.gnss = (bool)UBITS(94, 1); break; default: - gpsd_report(debug, LOG_ERROR, + gpsd_notify(errout, LOG_ERROR, "Unparsed AIVDM message type %d.\n",ais->type); return false; } diff --git a/driver_garmin.c b/driver_garmin.c index 27200b49..c32bf82b 100644 --- a/driver_garmin.c +++ b/driver_garmin.c @@ -847,7 +847,7 @@ static void Build_Send_SER_Packet(struct gps_device_t *session, // This works around cppcheck not looking into enough config branches // cppcheck-suppress unusedFunction static bool is_usb_device(const char *path UNUSED, int vendor, int product, - const int debug) + struct errout_t *errout) { // discover devices libusb_device **list; @@ -855,12 +855,12 @@ static bool is_usb_device(const char *path UNUSED, int vendor, int product, ssize_t i = 0; bool found = false; - gpsd_report(debug, LOG_INF, + gpsd_notify(errout, LOG_INF, "attempting USB device enumeration.\n"); (void)libusb_init(NULL); if ((cnt = libusb_get_device_list(NULL, &list)) < 0) { - gpsd_report(debug, LOG_ERROR, + gpsd_notify(errout, LOG_ERROR, "USB device list call failed.\n"); libusb_exit(NULL); return false; @@ -872,13 +872,13 @@ static bool is_usb_device(const char *path UNUSED, int vendor, int product, int r = libusb_get_device_descriptor(dev, &desc); if (r < 0) { - gpsd_report(debug, LOG_ERROR, + gpsd_notify(errout, LOG_ERROR, "USB descriptor fetch failed on device %zd.\n", i); continue; } /* we can extract device descriptor data */ - gpsd_report(debug, LOG_INF, + gpsd_notify(errout, LOG_INF, "%04x:%04x (bus %d, device %d)\n", desc.idVendor, desc.idProduct, libusb_get_bus_number(dev), @@ -891,7 +891,7 @@ static bool is_usb_device(const char *path UNUSED, int vendor, int product, } } - gpsd_report(debug, LOG_INF, + gpsd_notify(errout, LOG_INF, "vendor/product match with %04x:%04x %sfound\n", vendor, product, found ? "" : "not "); libusb_free_device_list(list, 1); @@ -941,7 +941,7 @@ static bool garmin_usb_detect(struct gps_device_t *session UNUSED) else { #ifdef HAVE_LIBUSB if (!is_usb_device(session->gpsdata.dev.path, 0x091e, 0x0003, - session->context->errout.debug)) + &session->context->errout)) return false; if (!gpsd_set_raw(session)) { @@ -795,7 +795,8 @@ const struct gps_type_t driver_trueNorth = { * **************************************************************************/ -static int oceanserver_send(const int debug, const int fd, const char *fmt, ...) +static int oceanserver_send(struct errout_t *errout, + const int fd, const char *fmt, ...) { int status; char buf[BUFSIZ]; @@ -808,10 +809,10 @@ static int oceanserver_send(const int debug, const int fd, const char *fmt, ...) status = (int)write(fd, buf, strlen(buf)); (void)tcdrain(fd); if (status == (int)strlen(buf)) { - gpsd_report(debug, LOG_IO, "=> GPS: %s\n", buf); + gpsd_notify(errout, LOG_IO, "=> GPS: %s\n", buf); return status; } else { - gpsd_report(debug, LOG_WARN, "=> GPS: %s FAILED\n", buf); + gpsd_notify(errout, LOG_WARN, "=> GPS: %s FAILED\n", buf); return -1; } } @@ -823,10 +824,10 @@ static void oceanserver_event_hook(struct gps_device_t *session, return; if (event == event_configure && session->lexer.counter == 0) { /* report in NMEA format */ - (void)oceanserver_send(session->context->errout.debug, + (void)oceanserver_send(&session->context->errout, session->gpsdata.gps_fd, "2\n"); /* ship all fields */ - (void)oceanserver_send(session->context->errout.debug, + (void)oceanserver_send(&session->context->errout, session->gpsdata.gps_fd, "X2047"); } } @@ -1344,7 +1345,7 @@ static bool aivdm_decode(const char *buf, size_t buflen, ais_context->decoded_frags = 0; /* decode the assembled binary packet */ - return ais_binary_decode(session->context->errout.debug, + return ais_binary_decode(&session->context->errout, ais, ais_context->bits, ais_context->bitlen, diff --git a/gpsd.h-tail b/gpsd.h-tail index 9f0bbfa9..718e5ba4 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -982,7 +982,7 @@ extern /*@observer@*/const char *gpsd_maskdump(gps_mask_t); /* exceptional driver methods */ extern bool ubx_write(struct gps_device_t *, unsigned int, unsigned int, /*@null@*/unsigned char *, size_t); -extern bool ais_binary_decode(const int debug, +extern bool ais_binary_decode(const struct errout_t *errout, struct ais_t *ais, const unsigned char *, size_t, /*@null@*/struct ais_type24_queue_t *); @@ -141,7 +141,7 @@ unsigned int isgps_parity(isgps30bits_t th) /*@ -charint @*/ #ifdef __UNUSED__ - gpsd_report(ISGPS_ERRLEVEL_BASE + 2, "ISGPS parity %u\n", p); + gpsd_notify(errout, ISGPS_ERRLEVEL_BASE + 2, "ISGPS parity %u\n", p); #endif /* __UNUSED__ */ return (p); } diff --git a/net_ntrip.c b/net_ntrip.c index 4bc770a3..850b2f25 100644 --- a/net_ntrip.c +++ b/net_ntrip.c @@ -36,7 +36,7 @@ static /*@null@*/ char *ntrip_field_iterate( /*@null@ */ char *start, /*@null@*/ char *prev, const char *eol, - const int debug) + const struct errout_t *errout) { char *s, *t, *u; @@ -58,7 +58,7 @@ static /*@null@*/ char *ntrip_field_iterate( /*@null@ */ char *start, if ((t = strstr(t, ";"))) *t = '\0'; - gpsd_report(debug, LOG_RAW, "Next Ntrip source table field %s\n", s); + gpsd_notify(errout, LOG_RAW, "Next Ntrip source table field %s\n", s); return s; } @@ -68,19 +68,19 @@ static /*@null@*/ char *ntrip_field_iterate( /*@null@ */ char *start, /*@ -mustfreefresh @*/ static void ntrip_str_parse(char *str, size_t len, /*@out@*/ struct ntrip_stream_t *hold, - const int debug) + const struct errout_t *errout) { char *s, *eol = str + len; memset(hold, 0, sizeof(*hold)); /* <mountpoint> */ - if ((s = ntrip_field_iterate(str, NULL, eol, debug))) + if ((s = ntrip_field_iterate(str, NULL, eol, errout))) (void)strlcpy(hold->mountpoint, s, sizeof(hold->mountpoint)); /* <identifier> */ - s = ntrip_field_iterate(NULL, s, eol, debug); + s = ntrip_field_iterate(NULL, s, eol, errout); /* <format> */ - if ((s = ntrip_field_iterate(NULL, s, eol, debug))) { + if ((s = ntrip_field_iterate(NULL, s, eol, errout))) { if (strcasecmp("RTCM 2", s) == 0) hold->format = fmt_rtcm2; else if (strcasecmp("RTCM 2.0", s) == 0) @@ -100,41 +100,41 @@ static void ntrip_str_parse(char *str, size_t len, hold->format = fmt_unknown; } /* <format-details> */ - s = ntrip_field_iterate(NULL, s, eol, debug); + s = ntrip_field_iterate(NULL, s, eol, errout); /* <carrier> */ - if ((s = ntrip_field_iterate(NULL, s, eol, debug))) + if ((s = ntrip_field_iterate(NULL, s, eol, errout))) hold->carrier = atoi(s); /* <nav-system> */ - s = ntrip_field_iterate(NULL, s, eol, debug); + s = ntrip_field_iterate(NULL, s, eol, errout); /* <network> */ - s = ntrip_field_iterate(NULL, s, eol, debug); + s = ntrip_field_iterate(NULL, s, eol, errout); /* <country> */ - s = ntrip_field_iterate(NULL, s, eol, debug); + s = ntrip_field_iterate(NULL, s, eol, errout); /* <latitude> */ hold->latitude = NAN; - if ((s = ntrip_field_iterate(NULL, s, eol, debug))) + if ((s = ntrip_field_iterate(NULL, s, eol, errout))) hold->latitude = atof(s); /* <longitude> */ hold->longitude = NAN; - if ((s = ntrip_field_iterate(NULL, s, eol, debug))) + if ((s = ntrip_field_iterate(NULL, s, eol, errout))) hold->longitude = atof(s); /* <nmea> */ - if ((s = ntrip_field_iterate(NULL, s, eol, debug))) { + if ((s = ntrip_field_iterate(NULL, s, eol, errout))) { hold->nmea = atoi(s); } /* <solution> */ - s = ntrip_field_iterate(NULL, s, eol, debug); + s = ntrip_field_iterate(NULL, s, eol, errout); /* <generator> */ - s = ntrip_field_iterate(NULL, s, eol, debug); + s = ntrip_field_iterate(NULL, s, eol, errout); /* <compr-encryp> */ - if ((s = ntrip_field_iterate(NULL, s, eol, debug))) { + if ((s = ntrip_field_iterate(NULL, s, eol, errout))) { if (strcasecmp("none", s) == 0) hold->compr_encryp = cmp_enc_none; else hold->compr_encryp = cmp_enc_unknown; } /* <authentication> */ - if ((s = ntrip_field_iterate(NULL, s, eol, debug))) { + if ((s = ntrip_field_iterate(NULL, s, eol, errout))) { if (strcasecmp("N", s) == 0) hold->authentication = auth_none; else if (strcasecmp("B", s) == 0) @@ -145,15 +145,15 @@ static void ntrip_str_parse(char *str, size_t len, hold->authentication = auth_unknown; } /* <fee> */ - if ((s = ntrip_field_iterate(NULL, s, eol, debug))) { + if ((s = ntrip_field_iterate(NULL, s, eol, errout))) { hold->fee = atoi(s); } /* <bitrate> */ - if ((s = ntrip_field_iterate(NULL, s, eol, debug))) { + if ((s = ntrip_field_iterate(NULL, s, eol, errout))) { hold->bitrate = atoi(s); } /* ...<misc> */ - while ((s = ntrip_field_iterate(NULL, s, eol, debug))); + while ((s = ntrip_field_iterate(NULL, s, eol, errout))); } static int ntrip_sourcetable_parse(struct gps_device_t *device) @@ -241,7 +241,7 @@ static int ntrip_sourcetable_parse(struct gps_device_t *device) if (strncmp(line, NTRIP_STR, strlen(NTRIP_STR)) == 0) { ntrip_str_parse(line + strlen(NTRIP_STR), (size_t) (llen - strlen(NTRIP_STR)), - &hold, device->context->errout.debug); + &hold, &device->context->errout); if (strcmp(device->ntrip.stream.mountpoint, hold.mountpoint) == 0) { /* todo: support for RTCM 3.0, SBAS (WAAS, EGNOS), ... */ if (hold.format == fmt_unknown) { @@ -307,7 +307,7 @@ done: } static int ntrip_stream_req_probe(const struct ntrip_stream_t *stream, - const int debug) + struct errout_t *errout) { int dsock; ssize_t r; @@ -315,10 +315,10 @@ static int ntrip_stream_req_probe(const struct ntrip_stream_t *stream, dsock = netlib_connectsock(AF_UNSPEC, stream->url, stream->port, "tcp"); if (dsock < 0) { - gpsd_report(debug, LOG_ERROR, "ntrip stream connect error %d in req probe\n", dsock); + gpsd_notify(errout, LOG_ERROR, "ntrip stream connect error %d in req probe\n", dsock); return -1; } - gpsd_report(debug, LOG_SPIN, "ntrip stream for req probe connected on fd %d\n", dsock); + gpsd_notify(errout, LOG_SPIN, "ntrip stream for req probe connected on fd %d\n", dsock); (void)snprintf(buf, sizeof(buf), "GET / HTTP/1.1\r\n" "User-Agent: NTRIP gpsd/%s\r\n" @@ -327,7 +327,7 @@ static int ntrip_stream_req_probe(const struct ntrip_stream_t *stream, "\r\n", VERSION, stream->url); r = write(dsock, buf, strlen(buf)); if (r != (ssize_t)strlen(buf)) { - gpsd_report(debug, LOG_ERROR, + gpsd_notify(errout, LOG_ERROR, "ntrip stream write error %d on fd %d during probe request %zd\n", errno, dsock, r); (void)close(dsock); @@ -364,19 +364,19 @@ static int ntrip_auth_encode(const struct ntrip_stream_t *stream, /* *INDENT-ON* */ static int ntrip_stream_get_req(const struct ntrip_stream_t *stream, - const int debug) + const struct errout_t *errout) { int dsock; char buf[BUFSIZ]; dsock = netlib_connectsock(AF_UNSPEC, stream->url, stream->port, "tcp"); if (BAD_SOCKET(dsock)) { - gpsd_report(debug, LOG_ERROR, + gpsd_notify(errout, LOG_ERROR, "ntrip stream connect error %d\n", dsock); return -1; } - gpsd_report(debug, LOG_SPIN, + gpsd_notify(errout, LOG_SPIN, "netlib_connectsock() returns socket on fd %d\n", dsock); @@ -389,7 +389,7 @@ static int ntrip_stream_get_req(const struct ntrip_stream_t *stream, "Connection: close\r\n" "\r\n", stream->mountpoint, VERSION, stream->url, stream->authStr); if (write(dsock, buf, strlen(buf)) != (ssize_t) strlen(buf)) { - gpsd_report(debug, LOG_ERROR, + gpsd_notify(errout, LOG_ERROR, "ntrip stream write error %d on fd %d during get request\n", errno, dsock); (void)close(dsock); @@ -399,7 +399,8 @@ static int ntrip_stream_get_req(const struct ntrip_stream_t *stream, } static int ntrip_stream_get_parse(const struct ntrip_stream_t *stream, - const int dsock, const int debug) + const int dsock, + const struct errout_t *errout) { /*@-nullpass@*/ char buf[BUFSIZ]; @@ -408,7 +409,7 @@ static int ntrip_stream_get_parse(const struct ntrip_stream_t *stream, while (read(dsock, buf, sizeof(buf) - 1) == -1) { if (errno == EINTR) continue; - gpsd_report(debug, LOG_ERROR, + gpsd_notify(errout, LOG_ERROR, "ntrip stream read error %d on fd %d during get rsp\n", errno, dsock); goto close; @@ -417,21 +418,21 @@ static int ntrip_stream_get_parse(const struct ntrip_stream_t *stream, /* parse 401 Unauthorized */ /* coverity[string_null] - guaranteed terminated by the memset above */ if (strstr(buf, NTRIP_UNAUTH)!=NULL) { - gpsd_report(debug, LOG_ERROR, + gpsd_notify(errout, LOG_ERROR, "not authorized for Ntrip stream %s/%s\n", stream->url, stream->mountpoint); goto close; } /* parse SOURCETABLE */ if (strstr(buf, NTRIP_SOURCETABLE)!=NULL) { - gpsd_report(debug, LOG_ERROR, + gpsd_notify(errout, LOG_ERROR, "Broadcaster doesn't recognize Ntrip stream %s:%s/%s\n", stream->url, stream->port, stream->mountpoint); goto close; } /* parse ICY 200 OK */ if (strstr(buf, NTRIP_ICY)==NULL) { - gpsd_report(debug, LOG_ERROR, + gpsd_notify(errout, LOG_ERROR, "Unknown reply %s from Ntrip service %s:%s/%s\n", buf, stream->url, stream->port, stream->mountpoint); goto close; @@ -528,7 +529,7 @@ int ntrip_open(struct gps_device_t *device, char *caster) sizeof(device->ntrip.stream.port)); ret = ntrip_stream_req_probe(&device->ntrip.stream, - device->context->errout.debug); + &device->context->errout); if (ret == -1) { device->ntrip.conn_state = ntrip_conn_err; return -1; @@ -551,7 +552,7 @@ int ntrip_open(struct gps_device_t *device, char *caster) return -1; } ret = ntrip_stream_get_req(&device->ntrip.stream, - device->context->errout.debug); + &device->context->errout); if (ret == -1) { device->ntrip.conn_state = ntrip_conn_err; return -1; @@ -562,7 +563,7 @@ int ntrip_open(struct gps_device_t *device, char *caster) case ntrip_conn_sent_get: ret = ntrip_stream_get_parse(&device->ntrip.stream, device->gpsdata.gps_fd, - device->context->errout.debug); + &device->context->errout); if (ret == -1) { device->ntrip.conn_state = ntrip_conn_err; return -1; @@ -86,7 +86,7 @@ gps_mask_t gpsd_interpret_subframe_raw(struct gps_device_t *session, /* you can find up to date almanac data for comparision here: * https://gps.afspc.af.mil/gps/Current/current.alm */ -static void subframe_almanac(const struct gps_context_t *context, +static void subframe_almanac(const struct errout_t *errout, uint8_t tSVID, uint32_t words[], uint8_t subframe, uint8_t sv, uint8_t data_id, @@ -126,7 +126,7 @@ static void subframe_almanac(const struct gps_context_t *context, almp->af0 |= ((words[9] >> 2) & 0x000007); almp->af0 = (short)uint2int(almp->af0, 11); almp->d_af0 = pow(2.0,-20) * almp->af0; - gpsd_notify(&context->errout, LOG_PROG, + gpsd_notify(errout, LOG_PROG, "50B: SF:%d SV:%2u TSV:%2u data_id %d e:%g toa:%lu " "deltai:%.10e Omegad:%.5e svh:%u sqrtA:%.10g Omega0:%.10e " "omega:%.10e M0:%.11e af0:%.5e af1:%.5e\n", @@ -752,7 +752,7 @@ gps_mask_t gpsd_interpret_subframe(struct gps_device_t *session, } if ( -1 < sv ) { subp->is_almanac = 1; - subframe_almanac(session->context, + subframe_almanac(&session->context->errout, subp->tSVID, words, subp->subframe_num, (uint8_t)sv, subp->data_id, &subp->sub4.almanac); @@ -774,7 +774,7 @@ gps_mask_t gpsd_interpret_subframe(struct gps_device_t *session, */ if ( 25 > subp->pageid ) { subp->is_almanac = 1; - subframe_almanac(session->context, + subframe_almanac(&session->context->errout, subp->tSVID, words, subp->subframe_num, subp->pageid, subp->data_id, &subp->sub5.almanac); } else if ( 51 == subp->pageid ) { |