summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2005-05-17 15:54:59 +0000
committerEric S. Raymond <esr@thyrsus.com>2005-05-17 15:54:59 +0000
commit313e808ffddcd233f78861f4e33e375617bc527f (patch)
tree0e7002e014879e3bd06cd71d08f38a7fc0be93d1
parent9121efd80b493f817e973391e5774ba4746073fe (diff)
downloadgpsd-313e808ffddcd233f78861f4e33e375617bc527f.tar.gz
Permit xgps to specify a device.
-rw-r--r--xgps.c26
-rw-r--r--xgps.xml31
2 files changed, 37 insertions, 20 deletions
diff --git a/xgps.c b/xgps.c
index 81fee891..ca63e64d 100644
--- a/xgps.c
+++ b/xgps.c
@@ -361,7 +361,7 @@ static char *get_resource(Widget w, char *name, char *default_value)
int main(int argc, char *argv[])
{
int option;
- char *colon, *server = NULL, *port = DEFAULT_GPSD_PORT;
+ char *colon1, *colon2, *device = NULL, *server = NULL, *port = DEFAULT_GPSD_PORT;
char *su, *au;
char *err_str = NULL;
@@ -395,16 +395,21 @@ altunits_ok:;
printf("xgps %s\n", VERSION);
exit(0);
case 'h': case '?': default:
- fputs("usage: xgps [-?hv] [-speedunits {mph,kph,knots}] [-altunits {ft,meters}] [server[:port]]\n", stderr);
+ fputs("usage: xgps [-?hv] [-speedunits {mph,kph,knots}] [-altunits {ft,meters}] [server[:port:[device]]]\n", stderr);
exit(1);
}
}
if (optind < argc) {
server = strdup(argv[optind]);
- colon = strchr(server, ':');
- if (colon != NULL) {
- server[colon - server] = '\0';
- port = colon + 1;
+ colon1 = strchr(server, ':');
+ if (colon1 != NULL) {
+ server[colon1 - server] = '\0';
+ port = strdup(colon1 + 1);
+ colon2 = strchr(server, ':');
+ if (colon2 != NULL) {
+ port[colon2 - port] = '\0';
+ device = colon2 + 1;
+ }
}
}
@@ -430,6 +435,15 @@ altunits_ok:;
timer = time(NULL);
gps_set_raw_hook(gpsdata, update_panel);
+
+ if (device) {
+ char *channelcmd = (char *)malloc(strlen(device)+3);
+
+ strcpy(channelcmd, "F=");
+ strcpy(channelcmd+2, device);
+ gps_query(channelcmd);
+ }
+
gps_query(gpsdata, "w+x\n");
XtAppAddInput(app, gpsdata->gps_fd,
diff --git a/xgps.xml b/xgps.xml
index c52c223e..11d7392f 100644
--- a/xgps.xml
+++ b/xgps.xml
@@ -47,20 +47,23 @@ support the feature) the locations of accessible satellites.</para>
<para><application>xgps</application> accepts an -h option as for
<application>gpsd</application>, or a -v option to dump the package
-version and exit. An optional argument may specify an
-server to get data from; a colon-separated suffix is taken as a port
-number. The misfeature of previous versions that allowed it to
-direct-connect to the serial device has been removed.</para>
-
-<para>The -speedunits option can be used to set the speed units for
-display; follow the keyword with knots for nautical miles per hour,
-kph for kilometres per hour, or mph for miles per hour. The default
-is miles per hour. This option can also be set as the X resource
-'speedunits'.</para>
-
-<para>The -altunits option can be used to set the altitude units for
-display; follow the keyword with 'meters' or 'feet'. The default
-is feet. This option can also be set as the X resource 'altunits'.</para>
+version and exit.</para>
+
+<para>An optional argument may specify a server to get data from; a
+colon-separated suffix is taken as a port number. If there is a second
+colon-separated suffix, that is taken as a device name to be handed
+to the daemon in an F= command.</para>
+
+<para>The <option>-speedunits</option> option can be used to set the
+speed units for display; follow the keyword with knots for nautical
+miles per hour, kph for kilometres per hour, or mph for miles per
+hour. The default is miles per hour. This option can also be set as
+the X resource 'speedunits'.</para>
+
+<para>The <option>-altunits</option> option can be used to set the
+altitude units for display; follow the keyword with 'meters' or
+'feet'. The default is feet. This option can also be set as the X
+resource 'altunits'.</para>
</refsect2>
<refsect2><title>xgpsspeed</title>