3

I'm trying to use the C++ integration with GPSD on a Pi. If I run GPSMON I can verify that I have a full fix without issue, however in my C++ program I am getting a fix with mode 0, which means "MODE UPDATE NOT SEEN YET".

The program isn't erroring out at the socket connection, so I'm not sure what's causing the disconnect.

Joshua Jackson
  • 348
  • 2
  • 11

1 Answers1

2

I suppose you are using libgps and libgpsmm. Your problem may be caused by a version incompatibility between gpsd daemon and libgps. I.e. the client (libgps) may speak a different version of the "API protocol" gpsd_json than the gpsd daemon. This may happen if you decided to build/link a static version of libgps -- which does not exactly match the version number of gpsd. Or if your client runs on a diffent machine than gpsd server.

I ran into same problem and it took me valuable time to figure out the reason:
JSON parser in libgps is designed badly. It ignores/discards JSON objects which contain name/value pairs, which are not known a priori.
So whole TPV messages from gpsd may be discarded and your client implementation shows no error message, neither libgps functions return an error code. Too bad.

Here it is (json.c, line 296+, @2016-07-27):

  if (cursor->attribute == NULL) {
      json_debug_trace((1,
                "Unknown attribute name '%s' (attributes begin with '%s').\n",
                attrbuf, attrs->attribute));
      /* don't update end here, leave at attribute start */
      return JSON_ERR_BADATTR;
  }

And here (libgps_json.c, line 27+, @2016-07-27):

static int json_tpv_read(const char *buf, struct gps_data_t *gpsdata, const char **endptr)
{
    const struct json_attr_t json_attrs_1[] = {
      {"class",  t_check,   .dflt.check = "TPV"},
      {"device", t_string,  .addr.string = gpsdata->dev.path, .len = sizeof(gpsdata->dev.path)},
      {"time",   t_time,    .addr.real = &gpsdata->fix.time, .dflt.real = NAN},
      ...

Use _gpsmm->enable_debug( level, stderr ) with level>=6 and compile libgps, libgpsmm with define CLIENTDEBUG_ENABLE to get the debug trace output.

git repositiory of gpsd sources tells us dates of recent incompatible changes on the gpsd_json protocol:

git commits:
2016-04-07 Add "status" to TPV for DGPS notification
2016-01-04 Address Savannah bug #46804: JSON satellite view parsing is somewhat broken.
2015-04-04 Add client-library parsing of PPS precision.
2015-01-24 In client library, "dip" member was missing from ATT parsing.

Releases:
3.11 23-Aug-2014
3.12 22-Feb-2015 incompatible
3.13 26-Feb-2015
3.14 14-Mar-2015
3.15 03-Jun-2015 incompatible
3.16 08-Jan-2016 incompatible
3.17 xx-xxx-xxxx incompatible

Do gpsd developers not care about client-server compatibility across versions? What about shared libgps library binary API/ABI stability then? It is missing versioning functions. Very unsafe also.
(Look at the comment git comment on the 2015-04-04 change mentioned above: Data is currently discarded, pending the next gps_data_t structure break.)

NorbertM
  • 1,226
  • 12
  • 22