summaryrefslogtreecommitdiff
path: root/gpsmon.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-03-05 22:40:13 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-03-05 22:40:13 +0000
commit64cff5768dcdafea68e4aaf4dbab5a7b7245454e (patch)
treee4bc5b386d796720d48ffe990330c5a69c985173 /gpsmon.c
parent15b2d3d206002593d7ac3aded129de5013a8866d (diff)
downloadgpsd-64cff5768dcdafea68e4aaf4dbab5a7b7245454e.tar.gz
Support changing cycle time with gpctl and gpsmon, if the device supports it.
Diffstat (limited to 'gpsmon.c')
-rw-r--r--gpsmon.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/gpsmon.c b/gpsmon.c
index faca4b2e..35353bff 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -413,6 +413,11 @@ int main (int argc, char **argv)
else
(void)fputc(' ', stdout);
(void)fputc(' ', stdout);
+ if ((*active)->driver->rate_switcher != NULL)
+ (void)fputc('x', stdout);
+ else
+ (void)fputc(' ', stdout);
+ (void)fputc(' ', stdout);
if ((*active)->driver->control_send != NULL)
(void)fputc('x', stdout);
else
@@ -605,6 +610,34 @@ int main (int argc, char **argv)
}
switch (line[0])
{
+ case 'c': /* change cycle time */
+ if (active == NULL)
+ monitor_complain("No device defined yet");
+ else if (serial) {
+ double rate = strtod(arg, NULL);
+ /* Ugh...should have a controlfd slot
+ * in the session structure, really
+ */
+ if ((*active)->driver->rate_switcher) {
+ int dfd = session.gpsdata.gps_fd;
+ session.gpsdata.gps_fd = controlfd;
+ if ((*active)->driver->rate_switcher(&session, rate)) {
+ monitor_dump_send();
+ } else
+ monitor_complain("Rate not supported.");
+ session.gpsdata.gps_fd = dfd;
+ } else
+ monitor_complain("Device type has no rate switcher");
+ } else {
+ line[0] = 'c';
+ /*@ -sefparams @*/
+ assert(write(session.gpsdata.gps_fd, line, strlen(line)) != -1);
+ /* discard response */
+ assert(read(session.gpsdata.gps_fd, buf, sizeof(buf)) != -1);
+ /*@ +sefparams @*/
+ }
+ break;
+
case 'i': /* start probing for subtype */
if (active == NULL)
monitor_complain("No GPS type detected.");
@@ -719,12 +752,12 @@ int main (int argc, char **argv)
*/
(void)tcdrain(session.gpsdata.gps_fd);
(void)usleep(50000);
- session.gpsdata.gps_fd = dfd;
(void)gpsd_set_speed(&session, speed,
(unsigned char)parity,
stopbits);
} else
monitor_complain("Speed/mode cobination not supported.");
+ session.gpsdata.gps_fd = dfd;
} else
monitor_complain("Device type has no speed switcher");
} else {