diff options
-rw-r--r-- | gps.h | 5 | ||||
-rw-r--r-- | libgps_json.c | 15 |
2 files changed, 15 insertions, 5 deletions
@@ -909,6 +909,7 @@ struct gps_data_t { #define CLEAR_SET 0x40000000u /* sentence starts a reporting cycle */ #define REPORT_SET 0x80000000u /* sentence ends a reporting cycle */ #define DATA_SET ~(ONLINE_SET|PACKET_SET|CLEAR_SET|REPORT_SET) +#define UNION_SET (RTCM2_SET|RTCM3_SET|AIS_SET|VERSION_SET|DEVICELIST_SET|ERROR_SET) double online; /* NZ if GPS is on line, 0 if not. * * Note: gpsd clears this time when sentences @@ -954,9 +955,8 @@ struct gps_data_t { void (*raw_hook)(struct gps_data_t *, char *, size_t len); /* Raw-mode hook for GPS data. */ void (*thread_hook)(struct gps_data_t *, char *, size_t len);/* Thread-callback hook for GPS data. */ - /* Private data - may be changed or removed */ + /* pack things never reported together to reduce structure size */ union { - /* pack things never reported together to reduce structure size */ /* unusual forms of sensor data that might come up the pipe */ struct rtcm2_t rtcm2; struct rtcm3_t rtcm3; @@ -974,6 +974,7 @@ struct gps_data_t { char error[80]; }; + /* Private data - may be changed or removed */ bool newstyle; /* have we seen a JSON response */ }; diff --git a/libgps_json.c b/libgps_json.c index e9069b68..cee37026 100644 --- a/libgps_json.c +++ b/libgps_json.c @@ -221,6 +221,7 @@ static int json_devicelist_read(const char *buf, } gpsdata->devices.time = timestamp(); + gpsdata->set =~ UNION_SET; gpsdata->set |= DEVICELIST_SET; return 0; } @@ -248,6 +249,7 @@ static int json_version_read(const char *buf, if (status != 0) return status; + gpsdata->set =~ UNION_SET; gpsdata->set |= VERSION_SET; return 0; } @@ -271,6 +273,7 @@ static int json_error_read(const char *buf, if (status != 0) return status; + gpsdata->set =~ UNION_SET; gpsdata->set |= ERR_SET; return 0; } @@ -292,8 +295,10 @@ int libgps_json_unpack(const char *buf, struct gps_data_t *gpsdata) return status; } else if (strstr(buf, "\"class\":\"WATCH\"") != 0) { status = json_watch_read(buf, &gpsdata->policy, NULL); - if (status == 0) + if (status == 0) { + gpsdata->set =~ UNION_SET; gpsdata->set |= POLICY_SET; + } return status; } else if (strstr(buf, "\"class\":\"VERSION\"") != 0) { return json_version_read(buf, gpsdata, NULL); @@ -302,8 +307,10 @@ int libgps_json_unpack(const char *buf, struct gps_data_t *gpsdata) status = json_rtcm2_read(buf, gpsdata->dev.path, sizeof(gpsdata->dev.path), &gpsdata->rtcm2, NULL); - if (status == 0) + if (status == 0) { + gpsdata->set =~ UNION_SET; gpsdata->set |= RTCM2_SET; + } return status; #endif /* RTCM104V2_ENABLE */ #ifdef AIVDM_ENABLE @@ -311,8 +318,10 @@ int libgps_json_unpack(const char *buf, struct gps_data_t *gpsdata) status = json_ais_read(buf, gpsdata->dev.path, sizeof(gpsdata->dev.path), &gpsdata->ais, NULL); - if (status == 0) + if (status == 0) { + gpsdata->set =~ UNION_SET; gpsdata->set |= AIS_SET; + } return status; #endif /* AIVDM_ENABLE */ } else if (strstr(buf, "\"class\":\"ERROR\"") != 0) { |