summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2013-10-03 01:09:57 -0400
committerEric S. Raymond <esr@thyrsus.com>2013-10-04 16:23:27 -0400
commit1824f1f7e85b21325076aa825212158bb8686500 (patch)
tree9e452c2952b372a27b7e155973025fc617a630de
parent2f60fb2e6e25437d39468798392f83d7e02677db (diff)
downloadgpsd-1824f1f7e85b21325076aa825212158bb8686500.tar.gz
We can now monitor low-level string sends through gpsmon.
Now we'll know exactly what's being sent on a UBX mode change.
-rw-r--r--gpsctl.c8
-rw-r--r--gpsd.c8
-rw-r--r--gpsd.h-tail5
-rw-r--r--gpsdecode.c8
-rw-r--r--gpsmon.c15
-rw-r--r--serial.c3
-rw-r--r--test_geoid.c8
-rw-r--r--test_packet.c8
8 files changed, 57 insertions, 6 deletions
diff --git a/gpsctl.c b/gpsctl.c
index 3ac74729..8d58f6b7 100644
--- a/gpsctl.c
+++ b/gpsctl.c
@@ -25,6 +25,14 @@ static int debuglevel;
static unsigned int timeout = 8;
static struct gps_context_t context;
+ssize_t gpsd_write(struct gps_device_t *session,
+ const char *buf,
+ const size_t len)
+/* pass low-level data to devices straight through */
+{
+ return gpsd_serial_write(session, buf, len);
+}
+
/*
* Set this as high or higher than the maximum number of subtype
* probes in drivers.c.
diff --git a/gpsd.c b/gpsd.c
index 3b9bb016..c79d84a1 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -162,6 +162,14 @@ static void onsig(int sig)
signalled = (sig_atomic_t) sig;
}
+ssize_t gpsd_write(struct gps_device_t *session,
+ const char *buf,
+ const size_t len)
+/* pass low-level data to devices straight through */
+{
+ return gpsd_serial_write(session, buf, len);
+}
+
void gpsd_report(const int debuglevel, const int errlevel,
const char *fmt, ...)
{
diff --git a/gpsd.h-tail b/gpsd.h-tail
index afc9dd08..878a7a25 100644
--- a/gpsd.h-tail
+++ b/gpsd.h-tail
@@ -728,7 +728,8 @@ extern void ntrip_report(struct gps_context_t *,
extern void gpsd_tty_init(struct gps_device_t *);
extern int gpsd_serial_open(struct gps_device_t *);
extern bool gpsd_set_raw(struct gps_device_t *);
-extern ssize_t gpsd_write(struct gps_device_t *, const char *, size_t);
+extern ssize_t gpsd_serial_write(struct gps_device_t *,
+ const char *, const size_t);
extern bool gpsd_next_hunt_setting(struct gps_device_t *);
extern int gpsd_switch_driver(struct gps_device_t *, char *);
extern void gpsd_set_speed(struct gps_device_t *, speed_t, char, unsigned int);
@@ -737,6 +738,8 @@ extern speed_t gpsd_get_speed_old(const struct gps_device_t *);
extern void gpsd_assert_sync(struct gps_device_t *);
extern void gpsd_close(struct gps_device_t *);
+extern ssize_t gpsd_write(struct gps_device_t *, const char *, const size_t);
+
extern void gpsd_time_init(struct gps_context_t *, time_t);
extern void gpsd_set_century(struct gps_device_t *);
extern timestamp_t gpsd_gpstime_resolve(/*@in@ */ struct gps_device_t *,
diff --git a/gpsdecode.c b/gpsdecode.c
index 27137cb9..61db9f74 100644
--- a/gpsdecode.c
+++ b/gpsdecode.c
@@ -27,6 +27,14 @@ static unsigned int typelist[32];
*
**************************************************************************/
+ssize_t gpsd_write(struct gps_device_t *session,
+ const char *buf,
+ const size_t len)
+/* pass low-level data to devices straight through */
+{
+ return gpsd_serial_write(session, buf, len);
+}
+
void gpsd_report(const int debuglevel, const int errlevel,
const char *fmt, ...)
{
diff --git a/gpsmon.c b/gpsmon.c
index 47fa0b3c..40d5d6a5 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -333,7 +333,6 @@ bool monitor_control_send( /*@in@*/ unsigned char *buf, size_t len)
context.readonly = false;
st = (*active)->driver->control_send(&session, (char *)buf, len);
context.readonly = true;
- monitor_dump_send((const char *)buf, len);
return (st != -1);
}
}
@@ -343,14 +342,22 @@ static bool monitor_raw_send( /*@in@*/ unsigned char *buf, size_t len)
if (!serial)
return false;
else {
- ssize_t st;
- st = write(session.gpsdata.gps_fd, (char *)buf, len);
- monitor_dump_send((const char *)buf, len);
+ ssize_t st = gpsd_write(&session, (char *)buf, len);
return (st > 0 && (size_t) st == len);
}
}
#endif /* CONTROLSEND_ENABLE */
+ssize_t gpsd_write(struct gps_device_t *session,
+ const char *buf,
+ const size_t len)
+/* log low-level data to the packet window as it pas */
+{
+ monitor_dump_send((const char *)buf, len);
+ (void)tcdrain(session->gpsdata.gps_fd);
+ return gpsd_serial_write(session, buf, len);
+}
+
/*****************************************************************************
*
* Main sequence and display machinery
diff --git a/serial.c b/serial.c
index 9cfa566b..c04ed530 100644
--- a/serial.c
+++ b/serial.c
@@ -526,7 +526,8 @@ int gpsd_serial_open(struct gps_device_t *session)
return session->gpsdata.gps_fd;
}
-ssize_t gpsd_write(struct gps_device_t * session, const char *buf, size_t len)
+ssize_t gpsd_serial_write(struct gps_device_t * session,
+ const char *buf, const size_t len)
{
ssize_t status;
bool ok;
diff --git a/test_geoid.c b/test_geoid.c
index 19e926ba..2392b1a8 100644
--- a/test_geoid.c
+++ b/test_geoid.c
@@ -10,6 +10,14 @@
#include "gpsd.h"
+ssize_t gpsd_write(struct gps_device_t *session,
+ const char *buf,
+ const size_t len)
+/* pass low-level data to devices straight through */
+{
+ return gpsd_serial_write(session, buf, len);
+}
+
void gpsd_report(const int debuglevel, const int errlevel,
const char *fmt, ...)
{
diff --git a/test_packet.c b/test_packet.c
index eee8e3e4..bb8bbe2c 100644
--- a/test_packet.c
+++ b/test_packet.c
@@ -17,6 +17,14 @@
static int verbose = 0;
+ssize_t gpsd_write(struct gps_device_t *session,
+ const char *buf,
+ const size_t len)
+/* pass low-level data to devices straight through */
+{
+ return gpsd_serial_write(session, buf, len);
+}
+
void gpsd_report(int debuglevel, int errlevel, const char *fmt, ...)
/* assemble command in printf(3) style, use stderr or syslog */
{