summaryrefslogtreecommitdiff
path: root/serial.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 /serial.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 'serial.c')
-rw-r--r--serial.c86
1 files changed, 43 insertions, 43 deletions
diff --git a/serial.c b/serial.c
index 0c76b36e..df6f9040 100644
--- a/serial.c
+++ b/serial.c
@@ -241,8 +241,8 @@ bool gpsd_set_raw(struct gps_device_t * session)
{
(void)cfmakeraw(&session->ttyset);
if (tcsetattr(session->gpsdata.gps_fd, TCIOFLUSH, &session->ttyset) == -1) {
- gpsd_report(&session->context->errout, LOG_ERROR,
- "error changing port attributes: %s\n", strerror(errno));
+ gpsd_log(&session->context->errout, LOG_ERROR,
+ "error changing port attributes: %s\n", strerror(errno));
return false;
}
@@ -374,10 +374,10 @@ void gpsd_set_speed(struct gps_device_t *session,
(void)usleep(200000);
(void)tcflush(session->gpsdata.gps_fd, TCIOFLUSH);
}
- gpsd_report(&session->context->errout, LOG_INF,
- "speed %u, %d%c%d\n",
- gpsd_get_speed(session), 9 - stopbits, parity,
- stopbits);
+ gpsd_log(&session->context->errout, LOG_INF,
+ "speed %u, %d%c%d\n",
+ gpsd_get_speed(session), 9 - stopbits, parity,
+ stopbits);
session->gpsdata.dev.baudrate = (unsigned int)speed;
session->gpsdata.dev.parity = parity;
@@ -420,13 +420,13 @@ int gpsd_serial_open(struct gps_device_t *session)
if (session->context->readonly
|| (session->sourcetype <= source_blockdev)) {
mode = (mode_t) O_RDONLY;
- gpsd_report(&session->context->errout, LOG_INF,
- "opening read-only GPS data source type %d and at '%s'\n",
- (int)session->sourcetype, session->gpsdata.dev.path);
+ gpsd_log(&session->context->errout, LOG_INF,
+ "opening read-only GPS data source type %d and at '%s'\n",
+ (int)session->sourcetype, session->gpsdata.dev.path);
} else {
- gpsd_report(&session->context->errout, LOG_INF,
- "opening GPS data source type %d at '%s'\n",
- (int)session->sourcetype, session->gpsdata.dev.path);
+ gpsd_log(&session->context->errout, LOG_INF,
+ "opening GPS data source type %d at '%s'\n",
+ (int)session->sourcetype, session->gpsdata.dev.path);
}
/*@ +boolops +type @*/
#ifdef ENABLE_BLUEZ
@@ -441,19 +441,19 @@ int gpsd_serial_open(struct gps_device_t *session)
if (connect(session->gpsdata.gps_fd, (struct sockaddr *) &addr, sizeof (addr)) == -1) {
if (errno != EINPROGRESS && errno != EAGAIN) {
(void)close(session->gpsdata.gps_fd);
- gpsd_report(&session->context->errout, LOG_ERROR,
- "bluetooth socket connect failed: %s\n",
- strerror(errno));
+ gpsd_log(&session->context->errout, LOG_ERROR,
+ "bluetooth socket connect failed: %s\n",
+ strerror(errno));
return -1;
}
- gpsd_report(&session->context->errout, LOG_ERROR,
- "bluetooth socket connect in progress or again : %s\n",
- strerror(errno));
+ gpsd_log(&session->context->errout, LOG_ERROR,
+ "bluetooth socket connect in progress or again : %s\n",
+ strerror(errno));
}
(void)fcntl(session->gpsdata.gps_fd, F_SETFL, (int)mode);
- gpsd_report(&session->context->errout, LOG_PROG,
- "bluez device open success: %s %s\n",
- session->gpsdata.dev.path, strerror(errno));
+ gpsd_log(&session->context->errout, LOG_PROG,
+ "bluez device open success: %s %s\n",
+ session->gpsdata.dev.path, strerror(errno));
} else
#endif /* BLUEZ */
{
@@ -463,20 +463,20 @@ int gpsd_serial_open(struct gps_device_t *session)
*/
if ((session->gpsdata.gps_fd =
open(session->gpsdata.dev.path, (int)(mode | O_NONBLOCK | O_NOCTTY))) == -1) {
- gpsd_report(&session->context->errout, LOG_ERROR,
- "device open failed: %s - retrying read-only\n",
- strerror(errno));
+ gpsd_log(&session->context->errout, LOG_ERROR,
+ "device open failed: %s - retrying read-only\n",
+ strerror(errno));
if ((session->gpsdata.gps_fd =
open(session->gpsdata.dev.path, O_RDONLY | O_NONBLOCK | O_NOCTTY)) == -1) {
- gpsd_report(&session->context->errout, LOG_ERROR,
- "read-only device open failed: %s\n",
- strerror(errno));
+ gpsd_log(&session->context->errout, LOG_ERROR,
+ "read-only device open failed: %s\n",
+ strerror(errno));
return -1;
}
- gpsd_report(&session->context->errout, LOG_PROG,
- "file device open success: %s\n",
- strerror(errno));
+ gpsd_log(&session->context->errout, LOG_PROG,
+ "file device open success: %s\n",
+ strerror(errno));
}
}
@@ -506,9 +506,9 @@ int gpsd_serial_open(struct gps_device_t *session)
* Don't touch devices already opened by another process.
*/
if (fusercount(session->gpsdata.dev.path) > 1) {
- gpsd_report(&session->context->errout, LOG_ERROR,
- "%s already opened by another process\n",
- session->gpsdata.dev.path);
+ gpsd_log(&session->context->errout, LOG_ERROR,
+ "%s already opened by another process\n",
+ session->gpsdata.dev.path);
(void)close(session->gpsdata.gps_fd);
session->gpsdata.gps_fd = -1;
return -1;
@@ -588,9 +588,9 @@ int gpsd_serial_open(struct gps_device_t *session)
session->gpsdata.dev.stopbits = 1;
}
- gpsd_report(&session->context->errout, LOG_SPIN,
- "open(%s) -> %d in gpsd_serial_open()\n",
- session->gpsdata.dev.path, session->gpsdata.gps_fd);
+ gpsd_log(&session->context->errout, LOG_SPIN,
+ "open(%s) -> %d in gpsd_serial_open()\n",
+ session->gpsdata.dev.path, session->gpsdata.gps_fd);
return session->gpsdata.gps_fd;
}
@@ -608,10 +608,10 @@ ssize_t gpsd_serial_write(struct gps_device_t * session,
/* extra guard prevents expensive hexdump calls */
if (session->context->errout.debug >= LOG_IO) {
char scratchbuf[MAX_PACKET_LENGTH*2+1];
- gpsd_report(&session->context->errout, LOG_IO,
- "=> GPS: %s%s\n",
- gpsd_packetdump(scratchbuf, sizeof(scratchbuf),
- (char *)buf, len), ok ? "" : " FAILED");
+ gpsd_log(&session->context->errout, LOG_IO,
+ "=> GPS: %s%s\n",
+ gpsd_packetdump(scratchbuf, sizeof(scratchbuf),
+ (char *)buf, len), ok ? "" : " FAILED");
}
return status;
}
@@ -721,9 +721,9 @@ void gpsd_close(struct gps_device_t *session)
(void)tcsetattr(session->gpsdata.gps_fd, TCSANOW,
&session->ttyset_old);
}
- gpsd_report(&session->context->errout, LOG_SPIN,
- "close(%d) in gpsd_close(%s)\n",
- session->gpsdata.gps_fd, session->gpsdata.dev.path);
+ gpsd_log(&session->context->errout, LOG_SPIN,
+ "close(%d) in gpsd_close(%s)\n",
+ session->gpsdata.gps_fd, session->gpsdata.dev.path);
(void)close(session->gpsdata.gps_fd);
session->gpsdata.gps_fd = -1;
}