summaryrefslogtreecommitdiff
path: root/gpsctl.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 /gpsctl.c
parent15b2d3d206002593d7ac3aded129de5013a8866d (diff)
downloadgpsd-64cff5768dcdafea68e4aaf4dbab5a7b7245454e.tar.gz
Support changing cycle time with gpctl and gpsmon, if the device supports it.
Diffstat (limited to 'gpsctl.c')
-rw-r--r--gpsctl.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/gpsctl.c b/gpsctl.c
index 46e58361..7e65a64c 100644
--- a/gpsctl.c
+++ b/gpsctl.c
@@ -74,7 +74,8 @@ static void onsig(int sig)
int main(int argc, char **argv)
{
int option, status;
- char *err_str, *device = NULL, *speed = NULL, *devtype = NULL, *control = NULL;
+ char *err_str, *device = NULL, *devtype = NULL;
+ char *speed = NULL, *control = NULL, *rate = NULL;
bool to_binary = false, to_nmea = false, reset = false;
bool lowlevel=false, echo=false;
struct gps_data_t *gpsdata = NULL;
@@ -84,12 +85,15 @@ int main(int argc, char **argv)
ssize_t cooklen = 0;
unsigned int timeout = 4;
-#define USAGE "usage: gpsctl [-l] [-b | -n | -r] [-D n] [-s speed] [-T timeout] [-V] [-t devtype] [-x control] [-e] <device>\n"
+#define USAGE "usage: gpsctl [-l] [-b | -n | -r] [-D n] [-s speed] [-c rate] [-T timeout] [-V] [-t devtype] [-x control] [-e] <device>\n"
while ((option = getopt(argc, argv, "befhlnrs:t:x:D:T:V")) != -1) {
switch (option) {
case 'b': /* switch to vendor binary mode */
to_binary = true;
break;
+ case 'c':
+ rate = optarg;
+ break;
case 'x': /* ship specified control string */
control = optarg;
lowlevel = true;
@@ -116,6 +120,10 @@ int main(int argc, char **argv)
(void)fputs("-s\t", stdout);
else
(void)fputc('\t', stdout);
+ if ((*dp)->rate_switcher != NULL)
+ (void)fputs("-c\t", stdout);
+ else
+ (void)fputc('\t', stdout);
if ((*dp)->control_send != NULL)
(void)fputs("-x\t", stdout);
else
@@ -234,7 +242,7 @@ int main(int argc, char **argv)
}
/* if no control operation was specified, just ID the device */
- if (speed==NULL && !to_nmea && !to_binary && !reset) {
+ if (speed==NULL && rate == NULL && !to_nmea && !to_binary && !reset) {
/* the O is to force a device binding */
(void)gps_query(gpsdata, "OFIB");
gpsd_report(LOG_SHOUT, "%s identified as %s at %d\n",
@@ -305,6 +313,9 @@ int main(int argc, char **argv)
gpsdata->gps_device,
speed, parity, stopbits);
}
+ if (rate != NULL) {
+ gps_query(gpsdata, "C=%\n", rate);
+ }
(void)gps_close(gpsdata);
exit(status);
} else if (reset) {
@@ -525,6 +536,24 @@ int main(int argc, char **argv)
}
}
}
+ if (rate) {
+ bool write_enable = context.readonly;
+ context.readonly = false;
+ if (session.device_type->rate_switcher == NULL) {
+ gpsd_report(LOG_ERROR,
+ "%s devices have no rate switcher.\n",
+ session.device_type->type_name);
+ status = 1;
+ } else {
+ double rate_dbl = strtod(rate, NULL);
+
+ if (!session.device_type->rate_switcher(&session, rate_dbl)) {
+ gpsd_report(LOG_ERROR, "rate switch failed.\n");
+ status = 1;
+ }
+ }
+ context.readonly = write_enable;
+ }
/*@ -compdef @*/
if (control) {
bool write_enable = context.readonly;