summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2005-02-23 14:26:50 +0000
committerEric S. Raymond <esr@thyrsus.com>2005-02-23 14:26:50 +0000
commit0683fc6f8bf89cca866d0fa84bea30c00243baf5 (patch)
tree1b668a813ac16dcae58dacd2ed5b458b00a5f4fd
parentc307861f1a7a801d4646e504f97115be6a692821 (diff)
downloadgpsd-0683fc6f8bf89cca866d0fa84bea30c00243baf5.tar.gz
Implemented the I command.
-rw-r--r--Makefile.am2
-rw-r--r--drivers.c2
-rw-r--r--gps.h19
-rwxr-xr-xgps.py4
-rw-r--r--gpsd.c3
-rw-r--r--gpsd.spec.in4
-rw-r--r--gpsd.xml18
-rwxr-xr-xgpsprof35
-rw-r--r--libgps.c6
9 files changed, 64 insertions, 29 deletions
diff --git a/Makefile.am b/Makefile.am
index 5d977d36..f14814a2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -43,7 +43,7 @@ gpsd_LDADD = $(LIBM) libgps.la -lm
#
# Build shared library
#
-libgps_la_LDFLAGS = -version-number 5:0:0
+libgps_la_LDFLAGS = -version-number 6:0:0
lib_LTLIBRARIES = libgps.la
libgps_la_SOURCES = \
diff --git a/drivers.c b/drivers.c
index 4a085fd3..cae04f2c 100644
--- a/drivers.c
+++ b/drivers.c
@@ -157,7 +157,7 @@ static int sirf_validate_buffer(char *buf, size_t n)
struct gps_type_t sirfII = {
's', /* select explicitly with -T s */
- "SiRF-II", /* full name of type */
+ "SiRF-II NMEA", /* full name of type */
"$Ack Input105.", /* expected response to SiRF PSRF105 */
sirf_initializer, /* no initialization */
sirf_validate_buffer, /* how to check that we have good data */
diff --git a/gps.h b/gps.h
index 04d5f9e8..cb4c975b 100644
--- a/gps.h
+++ b/gps.h
@@ -94,6 +94,9 @@ struct gps_data_t {
int part, await; /* for tracking GSV parts */
struct life_t satellite_stamp;
+ /* what type gpsd thinks the device is */
+ char *gps_id; /* only valid if non-null. */
+
#ifdef PROFILING
/* profiling data for last sentence */
int profiling; /* profiling enabled? */
@@ -111,20 +114,24 @@ struct gps_data_t {
int baudrate, stopbits; /* RS232 link paramters */
int cycle; /* refresh cycle time in seconds */
- /* track which sentences have been seen */
- int seen_sentences;
+ /* these members are private */
+ int gps_fd; /* socket or file descriptor to GPS */
+ void (*raw_hook)(char *buf);/* Raw-mode hook for GPS data. */
+ int seen_sentences; /* track which sentences have been seen */
#define GPRMC 0x01
#define GPGGA 0x02
#define GPGLL 0x04
#define GPVTG 0x08
#define GPGSA 0x10
#define GPGSV 0x20
-
- /* these members are private */
- int gps_fd; /* socket or file descriptor to GPS */
- void (*raw_hook)(char *buf);/* Raw-mode hook for GPS data. */
};
+struct map_t {
+ const char *name;
+ const int value;
+};
+extern struct map_t *sentence_map;
+
struct gps_data_t *gps_open(const char *host, const char *port);
int gps_close(struct gps_data_t *);
int gps_query(struct gps_data_t *gpsdata, const char *requests);
diff --git a/gps.py b/gps.py
index 9d2bbea8..962a19c0 100755
--- a/gps.py
+++ b/gps.py
@@ -74,6 +74,8 @@ class gpsdata:
self.satellite_stamp = gps.timestamp(now)
self.await = self.parts = 0
+ self.gps_id = None
+
self.profiling = False
self.tag = ""
self.length = 0
@@ -214,6 +216,8 @@ class gps(gpsdata):
self.cycle = int(data)
elif cmd in ('D', 'd'):
self.utc = data
+ elif cmd in ('I', 'i'):
+ self.gps_id = data
elif cmd in ('M', 'm'):
i1 = int(data)
self.mode_stamp.changed = (self.mode != i1)
diff --git a/gpsd.c b/gpsd.c
index 3e7458ea..1418a62f 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -236,6 +236,9 @@ static int handle_request(int fd, char *buf, int buflen)
} else
strcpy(phrase, ",D=?");
break;
+ case 'I':
+ sprintf(phrase, ",I=%s", session->device_type->typename);
+ break;
case 'L':
sprintf(phrase, ",l=1 " VERSION " abcdmpqrstvwxy");
break;
diff --git a/gpsd.spec.in b/gpsd.spec.in
index 56bb820d..d5e73e4d 100644
--- a/gpsd.spec.in
+++ b/gpsd.spec.in
@@ -1,5 +1,5 @@
Name: gpsd
-%define SO3VERSION 5.0.0
+%define SO3VERSION 6.0.0
%define SO1VERSION 2
Summary: service daemon for mediating access to a GPS
Version: @VERSION@
@@ -128,7 +128,7 @@ if [ -d /etc/udev/rules.d/ ]; then rm /etc/udev/rules.d/80-gpsd.rules; fi
- Pass zero magnetic variation in generated NMEA from binary GPSes
correctly. Use O_SYNC rather than timeouts to guarantee that
baud-rate change strings get to the GPS before changing the line
- parameters.
+ parameters. Introduced I command.
* Mon Feb 21 2005 Eric S. Raymond <esr@snark.thyrsus.com> - 2.13-1
- Correct a bug in binary-protocol dumping (applies to Zodiac and
diff --git a/gpsd.xml b/gpsd.xml
index a06500b4..8b4a04b5 100644
--- a/gpsd.xml
+++ b/gpsd.xml
@@ -38,8 +38,8 @@ and speedometer</refpurpose>
<arg choice='opt'>-h </arg>
<arg choice='opt'>-v </arg>
<arg choice='opt'><replaceable>server</replaceable></arg>
- <arg choice='opt'>--speedunits <group choice='req'><arg>mph</arg><arg>kph</arg><arg>knots</arg></group></arg>
- <arg choice='opt'>--altunits <group choice='req'><arg>feet</arg><arg>meters</arg></group></arg>
+ <arg choice='opt'>-speedunits <group choice='req'><arg>mph</arg><arg>kph</arg><arg>knots</arg></group></arg>
+ <arg choice='opt'>-altunits <group choice='req'><arg>feet</arg><arg>meters</arg></group></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>xgpsspeed</command>
@@ -47,7 +47,7 @@ and speedometer</refpurpose>
<arg choice='opt'>-nc <replaceable>X-color</replaceable></arg>
<arg choice='opt'>-h </arg>
<arg choice='opt'>-v </arg>
- <arg choice='opt'>--speedunits <group choice='req'><arg>mph</arg><arg>kph</arg><arg>knots</arg></group></arg>
+ <arg choice='opt'>-speedunits <group choice='req'><arg>mph</arg><arg>kph</arg><arg>knots</arg></group></arg>
<arg choice='opt'><replaceable>server</replaceable></arg>
</cmdsynopsis>
@@ -208,6 +208,12 @@ part will vary and may be zero.</para></listitem>
</varlistentry>
<varlistentry>
+<term>i</term>
+<listitem><para>Returns a text string identifying the GPS. The string
+may contain spaces and is terminated by CR-LF.</para></listitem>
+</varlistentry>
+
+<varlistentry>
<term>l</term>
<listitem><para>Returns three fields: a protocol revision number,
the gpsd version, and a list of accepted request letters.</para></listitem>
@@ -348,13 +354,13 @@ 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
+<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
+<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>
@@ -367,7 +373,7 @@ optional argument as for <application>gps</application>, or a -v
option to dump the package version and exit. Additionally, it accepts
-rv (reverse video) and -nc (needle color) options.</para>
-<para>The --speedunits option can be used to set the speed units for
+<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
diff --git a/gpsprof b/gpsprof
index 1c22ea49..236364f0 100755
--- a/gpsprof
+++ b/gpsprof
@@ -39,8 +39,10 @@ class uninstrumented:
"Total times without instrumentation."
name = "uninstrumented"
def header(self, fp):
- fp.write("# Uninstrumented total latency, %s, %dN%d, cycle %ds\n" % \
- (title, session.baudrate, session.stopbits, session.cycle))
+ fp.write("# Uninstrumented total latency, %s, %s, %dN%d, cycle %ds\n" % \
+ (title,
+ session.gps_id, session.baudrate,
+ session.stopbits, session.cycle))
def formatter(self, session, fp):
fp.write("%2.6lf\n" % (time.time() - gps.isotime(session.utc),))
return True
@@ -48,19 +50,22 @@ class uninstrumented:
fmt = '''
set autoscale
set key below
-set key title "Uninstrumented total latency, %s, %dN%d, cycle %ds"
+set key title "Uninstrumented total latency, %s, %s, %dN%d, cycle %ds"
plot "%s" using 0:1 title "Total time" with impulses
'''
return fmt % (title,
- session.baudrate, session.stopbits, session.cycle,
+ session.gps_id, session.baudrate,
+ session.stopbits, session.cycle,
file)
class rawplot:
"All measurement, no deductions."
name = "raw"
def header(self, fp):
- fp.write("# Raw latency data, %s, %dN%d, cycle %ds\n" % \
- (title, session.baudrate, session.stopbits, session.cycle))
+ fp.write("# Raw latency data, %s, %s, %dN%d, cycle %ds\n" % \
+ (title,
+ session.gps_id, session.baudrate,
+ session.stopbits, session.cycle))
fp.write("#\t")
for hn in ("T1", "E1", "D1", "W", "E2", "T2", "D2"):
fp.write("%8s\t" % hn)
@@ -85,7 +90,7 @@ class rawplot:
fmt = '''
set autoscale
set key below
-set key title "Raw latency data, %s, %dN%d, cycle %ds"
+set key title "Raw latency data, %s, %s, %dN%d, cycle %ds"
plot \
"%s" using 0:8 title "D2 = Client decode time" with impulses, \
"%s" using 0:7 title "T2 = TCP/IP latency" with impulses, \
@@ -96,7 +101,8 @@ plot \
"%s" using 0:2 title "E1 = GPS latency" with impulses
'''
return fmt % (title,
- session.baudrate, session.stopbits, session.cycle,
+ session.gps_id, session.baudrate,
+ session.stopbits, session.cycle,
file, file, file, file, file, file, file)
class splitplot:
@@ -106,8 +112,10 @@ class splitplot:
def __init__(self):
self.found = {}
def header(self, fp):
- fp.write("# Split latency data, %s, %dN%d, cycle %ds\n" % \
- (title, session.baudrate, session.stopbits, session.cycle))
+ fp.write("# Split latency data, %s, %s, %dN%d, cycle %ds\n" % \
+ (title,
+ session.gps_id, session.baudrate,
+ session.stopbits, session.cycle))
fp.write("#")
for s in splitplot.sentences:
fp.write("%8s\t" % s)
@@ -138,7 +146,7 @@ class splitplot:
fixed = '''
set autoscale
set key below
-set key title "Filtered latency data, %s, %dN%d, cycle %ds"
+set key title "Filtered latency data, %s, %s, %dN%d, cycle %ds"
plot \\
"%s" using 0:%d title "D2 = Client decode time" with impulses, \
"%s" using 0:%d title "T2 = TCP/IP latency" with impulses, \
@@ -149,7 +157,8 @@ plot \\
'''
sc = len(splitplot.sentences)
fmt = fixed % (title,
- session.baudrate, session.stopbits, session.cycle,
+ session.gps_id, session.baudrate,
+ session.stopbits, session.cycle,
file, sc+6,
file, sc+5,
file, sc+4,
@@ -220,7 +229,7 @@ if __name__ == '__main__':
session.query("b=%d" % speed)
if session.baudrate != speed:
sys.stderr.write("gpsprof: baud rate change failed.\n")
- session.query("w+bc")
+ session.query("w+bci")
if formatter != uninstrumented:
session.query("z+")
#session.set_raw_hook(lambda x: sys.stdout.write(x))
diff --git a/libgps.c b/libgps.c
index 4e126d6a..4fe9b89a 100644
--- a/libgps.c
+++ b/libgps.c
@@ -36,6 +36,8 @@ int gps_close(struct gps_data_t *gpsdata)
/* close a gpsd connection */
{
int retval = close(gpsdata->gps_fd);
+ if (gpsdata->gps_id)
+ free(gpsdata->gps_id);
free(gpsdata);
return retval;
}
@@ -78,6 +80,10 @@ static int gps_unpack(char *buf, struct gps_data_t *gpsdata)
case 'D':
strcpy(gpsdata->utc, sp+2);
break;
+ case 'I':
+ if (gpsdata->gps_id)
+ free(gpsdata->gps_id);
+ gpsdata->gps_id = strdup(sp+2);
case 'M':
i1 = atoi(sp+2);
gpsdata->mode_stamp.changed = (gpsdata->mode != i1);