diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2009-08-18 02:59:44 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2009-08-18 02:59:44 +0000 |
commit | e73b127df2fa7d22f21302ecb83dd901e37d3b6c (patch) | |
tree | 576ca09b963bcaad7fe0975ac240fdecd7dc02e5 | |
parent | bd2cd7dc05b3562d661ae96c0a21b5f257e8d51b (diff) | |
download | gpsd-e73b127df2fa7d22f21302ecb83dd901e37d3b6c.tar.gz |
Step one in making the client library speak new protocol.
-rw-r--r-- | gps_json.c | 4 | ||||
-rw-r--r-- | gps_json.h | 1 | ||||
-rw-r--r-- | gpsd.xml | 2 | ||||
-rw-r--r-- | libgps.c | 29 |
4 files changed, 25 insertions, 11 deletions
@@ -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}, }; @@ -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); @@ -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 @@ -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) |