summaryrefslogtreecommitdiff
path: root/libgpsd_core.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2015-03-07 11:51:15 -0500
committerEric S. Raymond <esr@thyrsus.com>2015-03-07 11:51:15 -0500
commitdf34a3add8df382eb852a67635c6859ee8cc657f (patch)
treec52183ba41403d093ad1ac971fa45c4ba1289f0c /libgpsd_core.c
parent9c49083f2afe799343a610912b0ed404b2ffad05 (diff)
downloadgpsd-df34a3add8df382eb852a67635c6859ee8cc657f.tar.gz
gpsd-report() -> gpsd_log()
This change is done so we can add a "log" hook to the pps_thread_t structure (this is not done yet) and harmonize with the name of the outer logging function. If that name had been left as gpsd_report() there would have been scope for bad confusion with the report_hook member. Also, remove two stray duplicative printf calls from the NMEA2000 driver (drivers shouldn't have printfs!) and fix one typo. This is a step towards factoring out ntplib. For that to happen, the PPS thread code needs to be decoupled from the core session structure. No logic changes. Object compatibility preserved. All regression tests pass.
Diffstat (limited to 'libgpsd_core.c')
-rw-r--r--libgpsd_core.c377
1 files changed, 190 insertions, 187 deletions
diff --git a/libgpsd_core.c b/libgpsd_core.c
index 1c3c91ca..50887d0e 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -114,7 +114,7 @@ static void visibilize(/*@out@*/char *outbuf, size_t outlen,
#endif /* !SQUELCH_ENABLE */
-static void gpsd_vreport(const struct gpsd_errout_t *errout,
+static void gpsd_vlog(const struct gpsd_errout_t *errout,
const int errlevel,
char *outbuf, size_t outlen,
const char *fmt, va_list ap)
@@ -188,7 +188,7 @@ static void gpsd_vreport(const struct gpsd_errout_t *errout,
#endif /* !SQUELCH_ENABLE */
}
-void gpsd_report(const struct gpsd_errout_t *errout,
+void gpsd_log(const struct gpsd_errout_t *errout,
const int errlevel,
const char *fmt, ...)
/* assemble msg in printf(3) style, use errout hook or syslog for delivery */
@@ -198,7 +198,7 @@ void gpsd_report(const struct gpsd_errout_t *errout,
buf[0] = '\0';
va_start(ap, fmt);
- gpsd_vreport(errout, errlevel, buf, sizeof(buf), fmt, ap);
+ gpsd_vlog(errout, errlevel, buf, sizeof(buf), fmt, ap);
va_end(ap);
}
@@ -216,9 +216,9 @@ static void gpsd_run_device_hook(struct gpsd_errout_t *errout,
{
struct stat statbuf;
if (stat(DEVICEHOOKPATH, &statbuf) == -1)
- gpsd_report(errout, LOG_PROG,
- "no %s present, skipped running %s hook\n",
- DEVICEHOOKPATH, hook);
+ gpsd_log(errout, LOG_PROG,
+ "no %s present, skipped running %s hook\n",
+ DEVICEHOOKPATH, hook);
else {
/*
* We make an exception to the no-malloc rule here because
@@ -228,21 +228,21 @@ static void gpsd_run_device_hook(struct gpsd_errout_t *errout,
size_t bufsize = strlen(DEVICEHOOKPATH) + 1 + strlen(device_name) + 1 + strlen(hook) + 1;
char *buf = malloc(bufsize);
if (buf == NULL)
- gpsd_report(errout, LOG_ERROR,
- "error allocating run-hook buffer\n");
+ gpsd_log(errout, LOG_ERROR,
+ "error allocating run-hook buffer\n");
else
{
int status;
(void)snprintf(buf, bufsize, "%s %s %s",
DEVICEHOOKPATH, device_name, hook);
- gpsd_report(errout, LOG_INF, "running %s\n", buf);
+ gpsd_log(errout, LOG_INF, "running %s\n", buf);
status = system(buf);
if (status == -1)
- gpsd_report(errout, LOG_ERROR, "error running %s\n", buf);
+ gpsd_log(errout, LOG_ERROR, "error running %s\n", buf);
else
- gpsd_report(errout, LOG_INF,
- "%s returned %d\n", DEVICEHOOKPATH,
- WEXITSTATUS(status));
+ gpsd_log(errout, LOG_INF,
+ "%s returned %d\n", DEVICEHOOKPATH,
+ WEXITSTATUS(status));
free(buf);
}
}
@@ -259,14 +259,14 @@ int gpsd_switch_driver(struct gps_device_t *session, char *type_name)
if (first_sync && strcmp(session->device_type->type_name, type_name) == 0)
return 0;
- gpsd_report(&session->context->errout, LOG_PROG,
- "switch_driver(%s) called...\n", type_name);
+ gpsd_log(&session->context->errout, LOG_PROG,
+ "switch_driver(%s) called...\n", type_name);
/*@ -compmempass @*/
for (dp = gpsd_drivers, i = 0; *dp; dp++, i++)
if (strcmp((*dp)->type_name, type_name) == 0) {
- gpsd_report(&session->context->errout, LOG_PROG,
- "selecting %s driver...\n",
- (*dp)->type_name);
+ gpsd_log(&session->context->errout, LOG_PROG,
+ "selecting %s driver...\n",
+ (*dp)->type_name);
gpsd_assert_sync(session);
/*@i@*/ session->device_type = *dp;
session->driver_index = i;
@@ -283,7 +283,8 @@ int gpsd_switch_driver(struct gps_device_t *session, char *type_name)
#endif /* RECONFIGURE_ENABLE */
return 1;
}
- gpsd_report(&session->context->errout, LOG_ERROR, "invalid GPS type \"%s\".\n", type_name);
+ gpsd_log(&session->context->errout, LOG_ERROR,
+ "invalid GPS type \"%s\".\n", type_name);
return 0;
/*@ +compmempass @*/
/*@+mustfreeonly@*/
@@ -371,8 +372,9 @@ void gpsd_deactivate(struct gps_device_t *session)
session->device_type->mode_switcher(session, 0);
}
#endif /* RECONFIGURE_ENABLE */
- gpsd_report(&session->context->errout, LOG_INF, "closing GPS=%s (%d)\n",
- session->gpsdata.dev.path, session->gpsdata.gps_fd);
+ gpsd_log(&session->context->errout, LOG_INF,
+ "closing GPS=%s (%d)\n",
+ session->gpsdata.dev.path, session->gpsdata.gps_fd);
#if defined(NMEA2000_ENABLE)
if (session->sourcetype == source_can)
(void)nmea2000_close(session);
@@ -429,9 +431,9 @@ int gpsd_open(struct gps_device_t *session)
session->gpsdata.gps_fd = netgnss_uri_open(session,
session->gpsdata.dev.path);
session->sourcetype = source_tcp;
- gpsd_report(&session->context->errout, LOG_SPIN,
- "netgnss_uri_open(%s) returns socket on fd %d\n",
- session->gpsdata.dev.path, session->gpsdata.gps_fd);
+ gpsd_log(&session->context->errout, LOG_SPIN,
+ "netgnss_uri_open(%s) returns socket on fd %d\n",
+ session->gpsdata.dev.path, session->gpsdata.gps_fd);
return session->gpsdata.gps_fd;
/* otherwise, could be an TCP data feed */
} else if (str_starts_with(session->gpsdata.dev.path, "tcp://")) {
@@ -441,22 +443,22 @@ int gpsd_open(struct gps_device_t *session)
INVALIDATE_SOCKET(session->gpsdata.gps_fd);
port = strchr(server, ':');
if (port == NULL) {
- gpsd_report(&session->context->errout, LOG_ERROR,
- "Missing colon in TCP feed spec.\n");
+ gpsd_log(&session->context->errout, LOG_ERROR,
+ "Missing colon in TCP feed spec.\n");
return -1;
}
*port++ = '\0';
- gpsd_report(&session->context->errout, LOG_INF,
- "opening TCP feed at %s, port %s.\n", server,
- port);
+ gpsd_log(&session->context->errout, LOG_INF,
+ "opening TCP feed at %s, port %s.\n", server,
+ port);
if ((dsock = netlib_connectsock(AF_UNSPEC, server, port, "tcp")) < 0) {
- gpsd_report(&session->context->errout, LOG_ERROR,
- "TCP device open error %s.\n",
- netlib_errstr(dsock));
+ gpsd_log(&session->context->errout, LOG_ERROR,
+ "TCP device open error %s.\n",
+ netlib_errstr(dsock));
return -1;
} else
- gpsd_report(&session->context->errout, LOG_SPIN,
- "TCP device opened on fd %d\n", dsock);
+ gpsd_log(&session->context->errout, LOG_SPIN,
+ "TCP device opened on fd %d\n", dsock);
session->gpsdata.gps_fd = dsock;
session->sourcetype = source_tcp;
return session->gpsdata.gps_fd;
@@ -468,22 +470,22 @@ int gpsd_open(struct gps_device_t *session)
INVALIDATE_SOCKET(session->gpsdata.gps_fd);
port = strchr(server, ':');
if (port == NULL) {
- gpsd_report(&session->context->errout, LOG_ERROR,
- "Missing colon in UDP feed spec.\n");
+ gpsd_log(&session->context->errout, LOG_ERROR,
+ "Missing colon in UDP feed spec.\n");
return -1;
}
*port++ = '\0';
- gpsd_report(&session->context->errout, LOG_INF,
- "opening UDP feed at %s, port %s.\n", server,
- port);
+ gpsd_log(&session->context->errout, LOG_INF,
+ "opening UDP feed at %s, port %s.\n", server,
+ port);
if ((dsock = netlib_connectsock(AF_UNSPEC, server, port, "udp")) < 0) {
- gpsd_report(&session->context->errout, LOG_ERROR,
- "UDP device open error %s.\n",
- netlib_errstr(dsock));
+ gpsd_log(&session->context->errout, LOG_ERROR,
+ "UDP device open error %s.\n",
+ netlib_errstr(dsock));
return -1;
} else
- gpsd_report(&session->context->errout, LOG_SPIN,
- "UDP device opened on fd %d\n", dsock);
+ gpsd_log(&session->context->errout, LOG_SPIN,
+ "UDP device opened on fd %d\n", dsock);
session->gpsdata.gps_fd = dsock;
session->sourcetype = source_udp;
return session->gpsdata.gps_fd;
@@ -500,17 +502,17 @@ int gpsd_open(struct gps_device_t *session)
port = DEFAULT_GPSD_PORT;
} else
*port++ = '\0';
- gpsd_report(&session->context->errout, LOG_INF,
- "opening remote gpsd feed at %s, port %s.\n",
- server, port);
+ gpsd_log(&session->context->errout, LOG_INF,
+ "opening remote gpsd feed at %s, port %s.\n",
+ server, port);
if ((dsock = netlib_connectsock(AF_UNSPEC, server, port, "tcp")) < 0) {
- gpsd_report(&session->context->errout, LOG_ERROR,
- "remote gpsd device open error %s.\n",
- netlib_errstr(dsock));
+ gpsd_log(&session->context->errout, LOG_ERROR,
+ "remote gpsd device open error %s.\n",
+ netlib_errstr(dsock));
return -1;
} else
- gpsd_report(&session->context->errout, LOG_SPIN,
- "remote gpsd feed opened on fd %d\n", dsock);
+ gpsd_log(&session->context->errout, LOG_SPIN,
+ "remote gpsd feed opened on fd %d\n", dsock);
/*@+branchstate +nullpass@*/
/* watch to remote is issued when WATCH is */
session->gpsdata.gps_fd = dsock;
@@ -551,34 +553,34 @@ int gpsd_activate(struct gps_device_t *session, const int mode)
/*@ -mustfreeonly @*/
for (dp = gpsd_drivers; *dp; dp++) {
if ((*dp)->probe_detect != NULL) {
- gpsd_report(&session->context->errout, LOG_PROG,
- "Probing \"%s\" driver...\n",
- (*dp)->type_name);
+ gpsd_log(&session->context->errout, LOG_PROG,
+ "Probing \"%s\" driver...\n",
+ (*dp)->type_name);
/* toss stale data */
(void)tcflush(session->gpsdata.gps_fd, TCIOFLUSH);
if ((*dp)->probe_detect(session) != 0) {
- gpsd_report(&session->context->errout, LOG_PROG,
- "Probe found \"%s\" driver...\n",
- (*dp)->type_name);
+ gpsd_log(&session->context->errout, LOG_PROG,
+ "Probe found \"%s\" driver...\n",
+ (*dp)->type_name);
session->device_type = *dp;
gpsd_assert_sync(session);
goto foundit;
} else
- gpsd_report(&session->context->errout, LOG_PROG,
- "Probe not found \"%s\" driver...\n",
- (*dp)->type_name);
+ gpsd_log(&session->context->errout, LOG_PROG,
+ "Probe not found \"%s\" driver...\n",
+ (*dp)->type_name);
}
}
/*@ +mustfreeonly @*/
- gpsd_report(&session->context->errout, LOG_PROG,
- "no probe matched...\n");
+ gpsd_log(&session->context->errout, LOG_PROG,
+ "no probe matched...\n");
}
foundit:
#endif /* NON_NMEA_ENABLE */
gpsd_clear(session);
- gpsd_report(&session->context->errout, LOG_INF,
- "gpsd_activate(%d): activated GPS (fd %d)\n",
- session->mode, session->gpsdata.gps_fd);
+ gpsd_log(&session->context->errout, LOG_INF,
+ "gpsd_activate(%d): activated GPS (fd %d)\n",
+ session->mode, session->gpsdata.gps_fd);
/*
* We might know the device's type, but we shouldn't assume it has
* retained its settings. A revert hook might well have undone
@@ -696,7 +698,7 @@ static gps_mask_t fill_dop(const struct gpsd_errout_t *errout,
memset(satpos, 0, sizeof(satpos));
- gpsd_report(errout, LOG_INF, "Sats used (%d):\n", gpsdata->satellites_used);
+ gpsd_log(errout, LOG_INF, "Sats used (%d):\n", gpsdata->satellites_used);
for (n = k = 0; k < gpsdata->satellites_visible; k++) {
if (gpsdata->skyview[k].used && !SBAS_PRN(gpsdata->skyview[k].PRN))
{
@@ -707,11 +709,11 @@ static gps_mask_t fill_dop(const struct gpsd_errout_t *errout,
* cos(sp->elevation * DEG_2_RAD);
satpos[n][2] = sin(sp->elevation * DEG_2_RAD);
satpos[n][3] = 1;
- gpsd_report(errout, LOG_INF, "PRN=%3d az=%3d el=%2d (%f, %f, %f)\n",
- gpsdata->skyview[k].PRN,
- gpsdata->skyview[k].azimuth,
- gpsdata->skyview[k].elevation,
- satpos[n][0], satpos[n][1], satpos[n][2]);
+ gpsd_log(errout, LOG_INF, "PRN=%3d az=%3d el=%2d (%f, %f, %f)\n",
+ gpsdata->skyview[k].PRN,
+ gpsdata->skyview[k].azimuth,
+ gpsdata->skyview[k].elevation,
+ satpos[n][0], satpos[n][1], satpos[n][2]);
n++;
}
}
@@ -719,9 +721,9 @@ static gps_mask_t fill_dop(const struct gpsd_errout_t *errout,
/* If we don't have 4 satellites then we don't have enough information to calculate DOPS */
if (n < 4) {
#ifdef __UNUSED__
- gpsd_report(errout, LOG_DATA + 2,
- "Not enough satellites available %d < 4:\n",
- n);
+ gpsd_log(errout, LOG_DATA + 2,
+ "Not enough satellites available %d < 4:\n",
+ n);
#endif /* __UNUSED__ */
return 0; /* Is this correct return code here? or should it be ERROR_SET */
}
@@ -730,10 +732,10 @@ static gps_mask_t fill_dop(const struct gpsd_errout_t *errout,
memset(inv, 0, sizeof(inv));
#ifdef __UNUSED__
- gpsd_report(errout, LOG_INF, "Line-of-sight matrix:\n");
+ gpsd_log(errout, LOG_INF, "Line-of-sight matrix:\n");
for (k = 0; k < n; k++) {
- gpsd_report(errout, LOG_INF, "%f %f %f %f\n",
- satpos[k][0], satpos[k][1], satpos[k][2], satpos[k][3]);
+ gpsd_log(errout, LOG_INF, "%f %f %f %f\n",
+ satpos[k][0], satpos[k][1], satpos[k][2], satpos[k][3]);
}
#endif /* __UNUSED__ */
@@ -747,10 +749,10 @@ static gps_mask_t fill_dop(const struct gpsd_errout_t *errout,
}
#ifdef __UNUSED__
- gpsd_report(errout, LOG_INF, "product:\n");
+ gpsd_log(errout, LOG_INF, "product:\n");
for (k = 0; k < 4; k++) {
- gpsd_report(errout, LOG_INF, "%f %f %f %f\n",
- prod[k][0], prod[k][1], prod[k][2], prod[k][3]);
+ gpsd_log(errout, LOG_INF, "%f %f %f %f\n",
+ prod[k][0], prod[k][1], prod[k][2], prod[k][3]);
}
#endif /* __UNUSED__ */
@@ -760,18 +762,18 @@ static gps_mask_t fill_dop(const struct gpsd_errout_t *errout,
* Note: this will print garbage unless all the subdeterminants
* are computed in the invert() function.
*/
- gpsd_report(errout, LOG_RAW, "inverse:\n");
+ gpsd_log(errout, LOG_RAW, "inverse:\n");
for (k = 0; k < 4; k++) {
- gpsd_report(errout, LOG_RAW,
- "%f %f %f %f\n",
- inv[k][0], inv[k][1], inv[k][2], inv[k][3]);
+ gpsd_log(errout, LOG_RAW,
+ "%f %f %f %f\n",
+ inv[k][0], inv[k][1], inv[k][2], inv[k][3]);
}
#endif /* __UNUSED__ */
} else {
#ifndef USE_QT
- gpsd_report(errout, LOG_DATA,
- "LOS matrix is singular, can't calculate DOPs - source '%s'\n",
- gpsdata->dev.path);
+ gpsd_log(errout, LOG_DATA,
+ "LOS matrix is singular, can't calculate DOPs - source '%s'\n",
+ gpsdata->dev.path);
#endif
return 0;
}
@@ -785,10 +787,11 @@ static gps_mask_t fill_dop(const struct gpsd_errout_t *errout,
gdop = sqrt(inv[0][0] + inv[1][1] + inv[2][2] + inv[3][3]);
#ifndef USE_QT
- gpsd_report(errout, LOG_DATA,
- "DOPS computed/reported: X=%f/%f, Y=%f/%f, H=%f/%f, V=%f/%f, P=%f/%f, T=%f/%f, G=%f/%f\n",
- xdop, dop->xdop, ydop, dop->ydop, hdop, dop->hdop, vdop,
- dop->vdop, pdop, dop->pdop, tdop, dop->tdop, gdop, dop->gdop);
+ gpsd_log(errout, LOG_DATA,
+ "DOPS computed/reported: X=%f/%f, Y=%f/%f, H=%f/%f, V=%f/%f, "
+ "P=%f/%f, T=%f/%f, G=%f/%f\n",
+ xdop, dop->xdop, ydop, dop->ydop, hdop, dop->hdop, vdop,
+ dop->vdop, pdop, dop->pdop, tdop, dop->tdop, gdop, dop->gdop);
#endif
/*@ -usedef @*/
@@ -984,7 +987,7 @@ int gpsd_await_data(/*@out@*/fd_set *rfds,
FD_ZERO(efds);
(void)memcpy((char *)rfds, (char *)all_fds, sizeof(fd_set));
- gpsd_report(errout, LOG_RAW + 2, "select waits\n");
+ gpsd_log(errout, LOG_RAW + 2, "select waits\n");
/*
* Poll for user commands or GPS data. The timeout doesn't
* actually matter here since select returns whenever one of
@@ -1017,7 +1020,7 @@ int gpsd_await_data(/*@out@*/fd_set *rfds,
}
return AWAIT_NOT_READY;
} else {
- gpsd_report(errout, LOG_ERROR, "select: %s\n", strerror(errno));
+ gpsd_log(errout, LOG_ERROR, "select: %s\n", strerror(errno));
return AWAIT_FAILED;
}
}
@@ -1035,9 +1038,9 @@ int gpsd_await_data(/*@out@*/fd_set *rfds,
for (i = 0; i < (int)FD_SETSIZE; i++)
if (FD_ISSET(i, rfds))
str_appendf(dbuf, sizeof(dbuf), " %d ", i);
- gpsd_report(errout, LOG_SPIN,
- "select() {%s} at %f (errno %d)\n",
- dbuf, timestamp(), errno);
+ gpsd_log(errout, LOG_SPIN,
+ "select() {%s} at %f (errno %d)\n",
+ dbuf, timestamp(), errno);
}
return AWAIT_GOT_INPUT;
@@ -1140,11 +1143,11 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
double gap = now - session->lexer.start_time;
if (gap > min_cycle)
- gpsd_report(&session->context->errout, LOG_WARN,
- "cycle-start detector failed.\n");
+ gpsd_log(&session->context->errout, LOG_WARN,
+ "cycle-start detector failed.\n");
else if (gap > quiet_time) {
- gpsd_report(&session->context->errout, LOG_PROG,
- "transmission pause of %f\n", gap);
+ gpsd_log(&session->context->errout, LOG_PROG,
+ "transmission pause of %f\n", gap);
session->sor = now;
session->lexer.start_char = session->lexer.char_counter;
}
@@ -1163,23 +1166,23 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
if (session->device_type != NULL) {
newlen = session->device_type->get_packet(session);
/* coverity[deref_ptr] */
- gpsd_report(&session->context->errout, LOG_RAW,
- "%s is known to be %s\n",
- session->gpsdata.dev.path,
- session->device_type->type_name);
+ gpsd_log(&session->context->errout, LOG_RAW,
+ "%s is known to be %s\n",
+ session->gpsdata.dev.path,
+ session->device_type->type_name);
} else {
newlen = generic_get(session);
}
/* update the scoreboard structure from the GPS */
- gpsd_report(&session->context->errout, LOG_RAW + 2,
- "%s sent %zd new characters\n",
- session->gpsdata.dev.path, newlen);
+ gpsd_log(&session->context->errout, LOG_RAW + 2,
+ "%s sent %zd new characters\n",
+ session->gpsdata.dev.path, newlen);
if (newlen < 0) { /* read error */
- gpsd_report(&session->context->errout, LOG_INF,
- "GPS on %s returned error %zd (%lf sec since data)\n",
- session->gpsdata.dev.path, newlen,
- timestamp() - session->gpsdata.online);
+ gpsd_log(&session->context->errout, LOG_INF,
+ "GPS on %s returned error %zd (%lf sec since data)\n",
+ session->gpsdata.dev.path, newlen,
+ timestamp() - session->gpsdata.online);
session->gpsdata.online = (timestamp_t)0;
return ERROR_SET;
} else if (newlen == 0) { /* zero length read, possible EOF */
@@ -1188,26 +1191,26 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
* wrong time...
*/
if (session->gpsdata.online > 0 && timestamp() - session->gpsdata.online >= session->gpsdata.dev.cycle * 2) {
- gpsd_report(&session->context->errout, LOG_INF,
- "GPS on %s is offline (%lf sec since data)\n",
- session->gpsdata.dev.path,
- timestamp() - session->gpsdata.online);
+ gpsd_log(&session->context->errout, LOG_INF,
+ "GPS on %s is offline (%lf sec since data)\n",
+ session->gpsdata.dev.path,
+ timestamp() - session->gpsdata.online);
session->gpsdata.online = (timestamp_t)0;
}
return NODATA_IS;
} else /* (newlen > 0) */ {
- gpsd_report(&session->context->errout, LOG_RAW,
- "packet sniff on %s finds type %d\n",
- session->gpsdata.dev.path, session->lexer.type);
+ gpsd_log(&session->context->errout, LOG_RAW,
+ "packet sniff on %s finds type %d\n",
+ session->gpsdata.dev.path, session->lexer.type);
if (session->lexer.type == COMMENT_PACKET) {
if (strcmp((const char *)session->lexer.outbuffer, "# EOF\n") == 0) {
- gpsd_report(&session->context->errout, LOG_PROG,
- "synthetic EOF\n");
+ gpsd_log(&session->context->errout, LOG_PROG,
+ "synthetic EOF\n");
return EOF_IS;
}
else
- gpsd_report(&session->context->errout, LOG_PROG,
- "comment, sync lock deferred\n");
+ gpsd_log(&session->context->errout, LOG_PROG,
+ "comment, sync lock deferred\n");
/* FALL THROUGH */
} else if (session->lexer.type > COMMENT_PACKET) {
if (session->device_type == NULL)
@@ -1247,9 +1250,9 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
for (dp = gpsd_drivers; *dp; dp++)
if (session->lexer.type == (*dp)->packet_type) {
- gpsd_report(&session->context->errout, LOG_PROG,
- "switching to match packet type %d: %s\n",
- session->lexer.type, gpsd_prettydump(session));
+ gpsd_log(&session->context->errout, LOG_PROG,
+ "switching to match packet type %d: %s\n",
+ session->lexer.type, gpsd_prettydump(session));
(void)gpsd_switch_driver(session, (*dp)->type_name);
break;
}
@@ -1259,26 +1262,26 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
session->gpsdata.dev.driver_mode = (session->lexer.type > NMEA_PACKET) ? MODE_BINARY : MODE_NMEA;
/* FALL THROUGH */
} else if (hunt_failure(session) && !gpsd_next_hunt_setting(session)) {
- gpsd_report(&session->context->errout, LOG_INF,
- "hunt on %s failed (%lf sec since data)\n",
- session->gpsdata.dev.path,
- timestamp() - session->gpsdata.online);
+ gpsd_log(&session->context->errout, LOG_INF,
+ "hunt on %s failed (%lf sec since data)\n",
+ session->gpsdata.dev.path,
+ timestamp() - session->gpsdata.online);
return ERROR_SET;
}
}
if (session->lexer.outbuflen == 0) { /* got new data, but no packet */
- gpsd_report(&session->context->errout, LOG_RAW + 3,
- "New data on %s, not yet a packet\n",
- session->gpsdata.dev.path);
+ gpsd_log(&session->context->errout, LOG_RAW + 3,
+ "New data on %s, not yet a packet\n",
+ session->gpsdata.dev.path);
return ONLINE_SET;
} else { /* we have recognized a packet */
gps_mask_t received = PACKET_SET;
session->gpsdata.online = timestamp();
- gpsd_report(&session->context->errout, LOG_RAW + 3,
- "Accepted packet on %s.\n",
- session->gpsdata.dev.path);
+ gpsd_log(&session->context->errout, LOG_RAW + 3,
+ "Accepted packet on %s.\n",
+ session->gpsdata.dev.path);
/* track the packet count since achieving sync on the device */
if (driver_change
@@ -1287,12 +1290,12 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
/*@-nullderef@*/
/* coverity[var_deref_op] */
- gpsd_report(&session->context->errout, LOG_INF,
- "%s identified as type %s, %f sec @ %ubps\n",
- session->gpsdata.dev.path,
- session->device_type->type_name,
- timestamp() - session->opentime,
- (unsigned int)speed);
+ gpsd_log(&session->context->errout, LOG_INF,
+ "%s identified as type %s, %f sec @ %ubps\n",
+ session->gpsdata.dev.path,
+ session->device_type->type_name,
+ timestamp() - session->opentime,
+ (unsigned int)speed);
/*@+nullderef@*/
/* fire the init_query method */
@@ -1333,11 +1336,11 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
* level does not actually require it.
*/
if (session->context->errout.debug >= LOG_RAW)
- gpsd_report(&session->context->errout, LOG_RAW,
- "raw packet of type %d, %zd:%s\n",
- session->lexer.type,
- session->lexer.outbuflen,
- gpsd_prettydump(session));
+ gpsd_log(&session->context->errout, LOG_RAW,
+ "raw packet of type %d, %zd:%s\n",
+ session->lexer.type,
+ session->lexer.outbuflen,
+ gpsd_prettydump(session));
/* Get data from current packet into the fix structure */
if (session->lexer.type != COMMENT_PACKET)
@@ -1358,9 +1361,9 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
&& session->last_controller != NULL)
{
session->device_type = session->last_controller;
- gpsd_report(&session->context->errout, LOG_PROG,
- "reverted to %s driver...\n",
- session->device_type->type_name);
+ gpsd_log(&session->context->errout, LOG_PROG,
+ "reverted to %s driver...\n",
+ session->device_type->type_name);
}
/*@+mustfreeonly@*/
#endif /* RECONFIGURE_ENABLE */
@@ -1397,7 +1400,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
/* don't downgrade mode if holding previous fix */
if (session->gpsdata.fix.mode > session->newdata.mode)
session->gpsdata.set &= ~MODE_SET;
- //gpsd_report(&session->context->errout, LOG_PROG,
+ //gpsd_log(&session->context->errout, LOG_PROG,
// "transfer mask: %02x\n", session->gpsdata.set);
gps_merge_fix(&session->gpsdata.fix,
session->gpsdata.set, &session->newdata);
@@ -1436,11 +1439,11 @@ gps_mask_t gpsd_poll(struct gps_device_t *session)
/*@+relaxtypes +longunsignedintegral@*/
if ((session->gpsdata.set & TIME_SET) != 0) {
if (session->newdata.time > time(NULL) + (60 * 60 * 24 * 365))
- gpsd_report(&session->context->errout, LOG_WARN,
- "date more than a year in the future!\n");
+ gpsd_log(&session->context->errout, LOG_WARN,
+ "date more than a year in the future!\n");
else if (session->newdata.time < 0)
- gpsd_report(&session->context->errout, LOG_ERROR,
- "date is negative!\n");
+ gpsd_log(&session->context->errout, LOG_ERROR,
+ "date is negative!\n");
}
/*@-relaxtypes -longunsignedintegral@*/
@@ -1458,8 +1461,8 @@ int gpsd_multipoll(const bool data_ready,
{
int fragments;
- gpsd_report(&device->context->errout, LOG_RAW + 1,
- "polling %d\n", device->gpsdata.gps_fd);
+ gpsd_log(&device->context->errout, LOG_RAW + 1,
+ "polling %d\n", device->gpsdata.gps_fd);
#ifdef NETFEED_ENABLE
/*
@@ -1471,8 +1474,8 @@ int gpsd_multipoll(const bool data_ready,
(void)ntrip_open(device, "");
if (device->ntrip.conn_state == ntrip_conn_err) {
- gpsd_report(&device->context->errout, LOG_WARN,
- "connection to ntrip server failed\n");
+ gpsd_log(&device->context->errout, LOG_WARN,
+ "connection to ntrip server failed\n");
device->ntrip.conn_state = ntrip_conn_init;
return DEVICE_ERROR;
} else {
@@ -1485,15 +1488,15 @@ int gpsd_multipoll(const bool data_ready,
gps_mask_t changed = gpsd_poll(device);
if (changed == EOF_IS) {
- gpsd_report(&device->context->errout, LOG_WARN,
- "device signed off %s\n",
- device->gpsdata.dev.path);
+ gpsd_log(&device->context->errout, LOG_WARN,
+ "device signed off %s\n",
+ device->gpsdata.dev.path);
return DEVICE_EOF;
} else if (changed == ERROR_SET) {
- gpsd_report(&device->context->errout, LOG_WARN,
- "device read of %s returned error or packet sniffer failed sync (flags %s)\n",
- device->gpsdata.dev.path,
- gps_maskdump(changed));
+ gpsd_log(&device->context->errout, LOG_WARN,
+ "device read of %s returned error or packet sniffer failed sync (flags %s)\n",
+ device->gpsdata.dev.path,
+ gps_maskdump(changed));
return DEVICE_ERROR;
} else if (changed == NODATA_IS) {
/*
@@ -1501,21 +1504,21 @@ int gpsd_multipoll(const bool data_ready,
* fd may have been in an end-of-file condition on select.
*/
if (fragments == 0) {
- gpsd_report(&device->context->errout, LOG_DATA,
- "%s returned zero bytes\n",
- device->gpsdata.dev.path);
+ gpsd_log(&device->context->errout, LOG_DATA,
+ "%s returned zero bytes\n",
+ device->gpsdata.dev.path);
if (device->zerokill) {
/* failed timeout-and-reawake, kill it */
gpsd_deactivate(device);
if (device->ntrip.works) {
device->ntrip.works = false; // reset so we try this once only
if (gpsd_activate(device, O_CONTINUE) < 0) {
- gpsd_report(&device->context->errout, LOG_WARN,
- "reconnect to ntrip server failed\n");
+ gpsd_log(&device->context->errout, LOG_WARN,
+ "reconnect to ntrip server failed\n");
return DEVICE_ERROR;
} else {
- gpsd_report(&device->context->errout, LOG_INFO,
- "reconnecting to ntrip server\n");
+ gpsd_log(&device->context->errout, LOG_INFO,
+ "reconnecting to ntrip server\n");
return DEVICE_READY;
}
}
@@ -1526,9 +1529,9 @@ int gpsd_multipoll(const bool data_ready,
* Disable listening to this fd for long enough
* that the buffer can fill up again.
*/
- gpsd_report(&device->context->errout, LOG_DATA,
- "%s will be repolled in %f seconds\n",
- device->gpsdata.dev.path, reawake_time);
+ gpsd_log(&device->context->errout, LOG_DATA,
+ "%s will be repolled in %f seconds\n",
+ device->gpsdata.dev.path, reawake_time);
device->reawake = timestamp() + reawake_time;
return DEVICE_UNREADY;
}
@@ -1553,15 +1556,15 @@ int gpsd_multipoll(const bool data_ready,
/* conditional prevents mask dumper from eating CPU */
if (device->context->errout.debug >= LOG_DATA) {
if (device->lexer.type == BAD_PACKET)
- gpsd_report(&device->context->errout, LOG_DATA,
- "packet with bad checksum from %s\n",
- device->gpsdata.dev.path);
+ gpsd_log(&device->context->errout, LOG_DATA,
+ "packet with bad checksum from %s\n",
+ device->gpsdata.dev.path);
else
- gpsd_report(&device->context->errout, LOG_DATA,
- "packet type %d from %s with %s\n",
- device->lexer.type,
- device->gpsdata.dev.path,
- gps_maskdump(device->gpsdata.set));
+ gpsd_log(&device->context->errout, LOG_DATA,
+ "packet type %d from %s with %s\n",
+ device->lexer.type,
+ device->gpsdata.dev.path,
+ gps_maskdump(device->gpsdata.set));
}
@@ -1586,9 +1589,9 @@ int gpsd_multipoll(const bool data_ready,
}
else if (device->reawake>0 && timestamp()>device->reawake) {
/* device may have had a zero-length read */
- gpsd_report(&device->context->errout, LOG_DATA,
- "%s reawakened after zero-length read\n",
- device->gpsdata.dev.path);
+ gpsd_log(&device->context->errout, LOG_DATA,
+ "%s reawakened after zero-length read\n",
+ device->gpsdata.dev.path);
device->reawake = (timestamp_t)0;
device->zerokill = true;
return DEVICE_READY;