summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gps.h61
-rw-r--r--gpsd.xml4
-rw-r--r--libgps.c14
3 files changed, 48 insertions, 31 deletions
diff --git a/gps.h b/gps.h
index 407ab412..bc9fa0c9 100644
--- a/gps.h
+++ b/gps.h
@@ -772,28 +772,6 @@ struct ais_t
};
};
-#define MAXDEVICES_PER_USER 4
-#define GPS_PATH_MAX 64 /* dev files usually have short names */
-#define TYPES_PER_DEVICE 4
-
-struct device_t {
- char path[GPS_PATH_MAX];
- int flags;
-#define SEEN_GPS 0x01
-#define SEEN_RTCM2 0x02
-#define SEEN_RTCM3 0x04
-#define SEEN_AIS 0x08
- char driver[64];
- char subtype[64];
- double activated;
-};
-
-struct version_t {
- char release[64]; /* external version */
- char rev[64]; /* internal revision ID */
- int api_major, api_minor; /* API major and minor versions */
-};
-
struct compass_t {
double magnetic_length; /* unitvector sqrt(x^2 + y^2 +z^2) */
double magnetic_field_x;
@@ -831,6 +809,38 @@ struct rawdata_t {
#define SAT_FIX_USED 0x40 /* used for position fix */
};
+/* following structures are for representing new-protocol responses */
+
+#define MAXDEVICES_PER_USER 4
+#define GPS_PATH_MAX 64 /* dev files usually have short names */
+#define TYPES_PER_DEVICE 4
+
+struct version_t {
+ char release[64]; /* external version */
+ char rev[64]; /* internal revision ID */
+ int api_major, api_minor; /* API major and minor versions */
+};
+
+struct device_t {
+ char path[GPS_PATH_MAX];
+ int flags;
+#define SEEN_GPS 0x01
+#define SEEN_RTCM2 0x02
+#define SEEN_RTCM3 0x04
+#define SEEN_AIS 0x08
+ char driver[64];
+ char subtype[64];
+ double activated;
+};
+
+struct watch_t {
+ int raw;
+ int buffer_polixy;
+ bool scaled;
+};
+
+/* this is the main structure that includes all previous substructures */
+
struct gps_data_t {
gps_mask_t set; /* has field been set since this was last cleared? */
#define ONLINE_SET 0x00000001u
@@ -912,17 +922,19 @@ struct gps_data_t {
/* pack things that are never reported together to reduce structure size */
union {
+ /* unusual forms of sensor data that might come up the pipe */
struct rtcm2_t rtcm2;
struct rtcm3_t rtcm3;
struct ais_t ais;
struct compass_t compass;
struct rawdata_t raw;
+ /* "artificial" structures for various protocol responses */
+ struct version_t version;
struct {
double time;
int ndevices;
struct device_t list[MAXDEVICES_PER_USER];
} devices;
- struct version_t version;
};
/* profiling data for last sentence */
@@ -968,6 +980,9 @@ extern void unix_to_gpstime(double, /*@out@*/int *, /*@out@*/double *);
extern double earth_distance(double, double, double, double);
extern double wgs84_separation(double, double);
+/* this only needs to be visible for the unit tests */
+extern int gps_unpack(char *, struct gps_data_t *);
+
/* some multipliers for interpreting GPS output */
#define METERS_TO_FEET 3.2808399 /* Meters to U.S./British feet */
#define METERS_TO_MILES 0.00062137119 /* Meters to miles */
diff --git a/gpsd.xml b/gpsd.xml
index 7f973028..4f396a72 100644
--- a/gpsd.xml
+++ b/gpsd.xml
@@ -1270,7 +1270,7 @@ they are never shipped outside of a SKY object.</para>
<term>?WATCH</term>
<listitem>
-<para>This command sets watcher mode/. It also sets or elicits a
+<para>This command sets watcher mode. It also sets or elicits a
report of per-subscriber buffering policy and the raw bit. An
argument WATCH object changes the subscriber's policy. The respunce
describes the subscriber's policy.</para>
@@ -1341,7 +1341,7 @@ describes the subscriber's policy.</para>
<para>Here's an example:</para>
<programlisting>
-{"class":"CONFIGHAN", "raw":1,"buffer_policy":1}
+{"class":"WATCH", "raw":1,"buffer_policy":1."scaled":true}
</programlisting>
</listitem>
diff --git a/libgps.c b/libgps.c
index b20aee4e..441a2308 100644
--- a/libgps.c
+++ b/libgps.c
@@ -68,7 +68,7 @@ void gps_set_raw_hook(struct gps_data_t *gpsdata,
}
/*@ -branchstate -usereleased -mustfreefresh @*/
-static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
+int gps_unpack(char *buf, struct gps_data_t *gpsdata)
/* unpack a gpsd response into a status structure, buf must be writeable */
{
char *ns, *sp, *tp;
@@ -440,6 +440,8 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
gpsdata->raw_hook(gpsdata, buf, strlen(buf), 1);
if (gpsdata->thread_hook)
gpsdata->thread_hook(gpsdata, buf, strlen(buf), 1);
+
+ return 0;
}
/*@ +nullstate +compdef @*/
/*@ -branchstate +usereleased +mustfreefresh @*/
@@ -455,6 +457,7 @@ int gps_poll(struct gps_data_t *gpsdata)
char buf[BUFSIZ];
ssize_t n;
double received = 0;
+ int status;
/* the daemon makes sure that every read is NUL-terminated */
n = read(gpsdata->gps_fd, buf, sizeof(buf)-1);
@@ -465,13 +468,13 @@ int gps_poll(struct gps_data_t *gpsdata)
buf[n] = '\0';
received = gpsdata->online = timestamp();
- gps_unpack(buf, gpsdata);
+ status = gps_unpack(buf, gpsdata);
if (gpsdata->profiling)
{
gpsdata->c_decode_time = received - gpsdata->fix.time;
gpsdata->c_recv_time = timestamp() - gpsdata->fix.time;
}
- return 0;
+ return status;
}
int gps_query(struct gps_data_t *gpsdata, const char *fmt, ... )
@@ -620,18 +623,17 @@ static void onsig(int sig)
exit(1);
}
-/* must start zeroed, otherwise the unit test will try to chase garbage pinter fields. */
+/* must start zeroed, otherwise the unit test will try to chase garbage pointer fields. */
struct gps_data_t gpsdata;
static char buf[] = "GPSD,O=RMC 1207318966.000 0.005 49.026225 12.188348 375.20 19.20 10.40 70.8900 24.899 0.000 75.6699 38.40 ? 3\r\n$GPVTG,70.89,T,,M,48.40,N,89.6,K,A*34\r\n";
static void unpack_unit_test(void)
/* torture the unpacking function */
{
-
(void)signal(SIGSEGV, onsig);
(void)signal(SIGBUS, onsig);
- gps_unpack(buf, &gpsdata);
+ (void)gps_unpack(buf, &gpsdata);
data_dump(&gpsdata, time(NULL));
}