diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2006-11-12 14:50:27 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2006-11-12 14:50:27 +0000 |
commit | 8f0029c8b3eaf4e9c64ce2cd31a3784060ea5bfc (patch) | |
tree | b287c657865e477d3dd9ac1c062b51c44c20b66d /gpsctl.c | |
parent | 45e9814cea45549822ccda7e24958b809363431f (diff) | |
download | gpsd-8f0029c8b3eaf4e9c64ce2cd31a3784060ea5bfc.tar.gz |
Several small fixes:
1. Make the configure message whem man pages aren't built more explicit.
2. Remove the *.5 generated pages.
3. Clear subtype info, if any, on on device close.
4. Document the gpsctl -s option.
Also, first steps towards a gpsctl type-forcing option.
Diffstat (limited to 'gpsctl.c')
-rw-r--r-- | gpsctl.c | 42 |
1 files changed, 38 insertions, 4 deletions
@@ -1,6 +1,6 @@ /* $Id$ */ /* - * gpsctrl.c -- tweak the control settings on a GPS + * gpsctl.c -- tweak the control settings on a GPS */ #include <stdio.h> #include <unistd.h> @@ -53,12 +53,13 @@ static gps_mask_t get_packet(struct gps_device_t *session) int main(int argc, char **argv) { int option, status; - char *err_str, *device = NULL, *speed = NULL; + char *err_str, *device = NULL, *speed = NULL, *devtype = NULL; bool to_binary = false, to_nmea = false, lowlevel=false; struct gps_data_t *gpsdata = NULL; + struct gps_type_t *forcetype = NULL; -#define USAGE "usage: gpsctl [-b | -n] [-s speed] [-V] <device>\n" - while ((option = getopt(argc, argv, "bfhns:D:V")) != -1) { +#define USAGE "usage: gpsctl [-b | -n] [-s speed] [-V] [-t devtype] <device>\n" + while ((option = getopt(argc, argv, "bfhns:t:D:V")) != -1) { switch (option) { case 'b': to_binary = true; @@ -72,6 +73,9 @@ int main(int argc, char **argv) case 's': speed = optarg; break; + case 't': + devtype = optarg; + break; case 'D': debuglevel = atoi(optarg); break; @@ -88,6 +92,26 @@ int main(int argc, char **argv) if (optind < argc) device = argv[optind]; + if (devtype) { + struct gps_type_t **dp; + int matchcount = 0; + for (dp = gpsd_drivers; *dp; dp++) { + if (strstr((*dp)->typename, devtype) != NULL) { + forcetype = *dp; + matchcount++; + } + } + if (matchcount == 0) + gpsd_report(LOG_ERROR, "gpsd: no driver name matches '%s'.\n", devtype); + else if (matchcount == 1) + gpsd_report(LOG_PROG, "gpsctl: %s driver selected.\n", forcetype->typename); + else { + forcetype = NULL; + gpsd_report(LOG_ERROR, "gpsd: %d driver names match '%s'.\n", + matchcount, devtype); + } + } + if (to_nmea && to_binary) { (void)fprintf(stderr, "gpsctl: make up your mind, would you?\n"); exit(0); @@ -204,6 +228,12 @@ int main(int argc, char **argv) } gpsd_report(LOG_PROG, "gpsctl: %s looks like a %s at %d.\n", device, gpsd_id(&session), session.gpsdata.baudrate); + + if (forcetype && strcmp("Generic NMEA", session.device_type->typename) !=0 && strcmp(forcetype->typename, session.device_type->typename)!=0) { + gpsd_report(LOG_ERROR, "gpsd: '%s' doesn't match non-generic type '%s' of selected device.", forcetype->typename, session.device_type->typename); + } + + /* * If we've identified this as an NMEA device, we have to eat * packets for a while to see if one of our probes elicits an @@ -231,6 +261,10 @@ int main(int argc, char **argv) if (speed==NULL && !to_nmea && !to_binary) exit(0); + /* control op specified; maybe we forced the type */ + if (forcetype) + gpsd_switch_driver(&session, forcetype->typename); + /* now perform the actual control function */ status = 0; if (to_nmea || to_binary) { |