summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-08-18 02:59:44 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-08-18 02:59:44 +0000
commite73b127df2fa7d22f21302ecb83dd901e37d3b6c (patch)
tree576ca09b963bcaad7fe0975ac240fdecd7dc02e5
parentbd2cd7dc05b3562d661ae96c0a21b5f257e8d51b (diff)
downloadgpsd-e73b127df2fa7d22f21302ecb83dd901e37d3b6c.tar.gz
Step one in making the client library speak new protocol.
-rw-r--r--gps_json.c4
-rw-r--r--gps_json.h1
-rw-r--r--gpsd.xml2
-rw-r--r--libgps.c29
4 files changed, 25 insertions, 11 deletions
diff --git a/gps_json.c b/gps_json.c
index b5e49a27..40b5b8ae 100644
--- a/gps_json.c
+++ b/gps_json.c
@@ -211,7 +211,7 @@ int json_sky_read(const char *buf, struct gps_data_t *gpsdata, const char **endp
const struct json_attr_t json_attrs_2[] = {
{"device", string, .addr.string.ptr = gpsdata->gps_device,
.addr.string.len = PATH_MAX},
- {"tag", string, .addr.string.ptr = gpsdata->tag,
+ {"tag", string, .addr.string.ptr = gpsdata->tag,
.addr.string.len = MAXTAGLEN},
{"time", real, .addr.real = &gpsdata->fix.time},
{"reported", integer, .addr.integer = &gpsdata->satellites_used},
@@ -282,6 +282,8 @@ int json_configdev_read(struct devconfig_t *cdp, const char *buf, const char **e
.addr.string.len=sizeof(cdp->serialmode)},
{"cycle", real, .addr.real = &cdp->cycle,
.dflt.real = NAN},
+ {"mincycle", real, .addr.real = &cdp->mincycle,
+ .dflt.real = NAN},
{NULL},
};
diff --git a/gps_json.h b/gps_json.h
index ddcaa0e6..47d4603b 100644
--- a/gps_json.h
+++ b/gps_json.h
@@ -11,6 +11,7 @@ struct devconfig_t {
int bps;
char serialmode[4];
double cycle;
+ double mincycle;
};
void json_tpv_dump(struct gps_data_t *, struct gps_fix_t *, char *, size_t);
void json_sky_dump(struct gps_data_t *, char *, size_t);
diff --git a/gpsd.xml b/gpsd.xml
index 6488435a..6543c504 100644
--- a/gpsd.xml
+++ b/gpsd.xml
@@ -1388,7 +1388,7 @@ extreme cases) physically disconnecting the NVRAM backup battery.</para>
<entry>Device cycle time in seconds.</entry>
</row>
<row>
- <entry>min_cycle</entry>
+ <entry>mincycle</entry>
<entry>No</entry>
<entry>real</entry>
<entry>Device minimum cycle time in seconds. Reported from
diff --git a/libgps.c b/libgps.c
index cec8e7e9..5f0cd93b 100644
--- a/libgps.c
+++ b/libgps.c
@@ -75,6 +75,17 @@ void gps_set_raw_hook(struct gps_data_t *gpsdata,
gpsdata->raw_hook = hook;
}
+#ifdef GPSDNG_ENABLE
+static void gps_json_unpack(char *buf, struct gps_data_t *gpsdata)
+{
+ if (strstr(buf, "\"class\":\"TPV\"") == 0) {
+ json_tpv_read(buf, gpsdata, NULL);
+ } else if (strstr(buf, "\"class\":\"SKY\"") == 0) {
+ json_sky_read(buf, gpsdata, NULL);
+ }
+}
+#endif /* GPSDNG_ENABLE */
+
/*@ -branchstate -usereleased -mustfreefresh @*/
static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
/* unpack a gpsd response into a status structure, buf must be writeable */
@@ -84,15 +95,14 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
#ifdef GPSDNG_ENABLE
/* detect and process a JSON response */
- /* FIXME: Needs top handle multiple responses per line. */
if (buf[0] == '{' && (sp = strchr(buf, '='))!= NULL) {
- if (strstr(buf, "\"class\":\"TPV\"") == 0) {
- json_tpv_read(buf, gpsdata, NULL);
- } else if (strstr(buf, "\"class\":\"SKY\"") == 0) {
- json_sky_read(buf, gpsdata, NULL);
- }
- } else
+ gps_json_unpack(buf, gpsdata);
+ }
#endif /* GPSDNG_ENABLE */
+#if defined(OLDSTYLE_ENABLE) && defined(GPSDNG_ENABLE)
+ else
+#endif /* defined(OLDSTYLE_ENABLE) && defined(GPSDNG_ENABLE) */
+#ifdef OLDSTYLE_ENABLE
{
/*
* Get the decimal separator for the current application locale.
@@ -175,13 +185,13 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
if (sp[2] != '?') {
char epe[20], eph[20], epv[20];
(void)sscanf(sp, "E=%s %s %s", epe, eph, epv);
- #define DEFAULT(val) (val[0] == '?') ? NAN : atof(val)
+#define DEFAULT(val) (val[0] == '?') ? NAN : atof(val)
/*@ +floatdouble @*/
gpsdata->epe = DEFAULT(epe);
gpsdata->fix.eph = DEFAULT(eph);
gpsdata->fix.epv = DEFAULT(epv);
/*@ -floatdouble @*/
- #undef DEFAULT
+#undef DEFAULT
}
break;
case 'F':
@@ -450,6 +460,7 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata)
}
}
}
+#endif /* GPSDNG_ENABLE */
/*@ -nullstate -compdef @*/
if (gpsdata->raw_hook)