gpsd-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do you access UBX MON-HW messages in a gpsd client


From: Thomas Giglia
Subject: Re: How do you access UBX MON-HW messages in a gpsd client
Date: Tue, 19 Mar 2024 19:21:21 +0000


I built/installed the source changes from the weekend.
When I tested it a couple of issues came up.
1. The satellites_used and satellites_visible don't get updated in my client. (they did with the old code)
2. The Latitude and Longitude have the wrong values now. (they did with the old code).
3. The "jam" field that was added to gps_fix_t is populated - allthough the value is not what I would expect.
   it bounces around 1,071,980,216 when no jamming signal is present, and jumps up to over 2,000,000,00 when
   I introduce a jamming signal.
4. To make matter worse (for me). The debug output from the gpsd server shows that it has the correct latitude
   and logitude. Its in the JSON/TPV output. In addition utilities like cgps or gpsmon have the right values.
   Seems like its just my client code that gets the wrong values (however the same code worked before).

I extracted what I am doing into a small program to test and show what I am doing:


#include <iostream>
#include <stdio.h>
#include <gps.h>
#include <math.h>
#include <libgpsmm.h>

using namespace std;

#define MODE_STR_NUM 4
static char *mode_str[MODE_STR_NUM] = {
    "n/a",
    "None",
    "2D",
    "3D"
};

void showGPSData(struct gps_data_t *data);
void showGPSData(struct gps_data_t *data)
{
 if(data == NULL)
 {
  cout<<"showGPSData: passed a NULL object!"<<endl;
  return;
 }
 cout<<"online: "<<data->online.tv_sec<<"."<<data->online.tv_nsec<<endl;
 cout<<"satellites_used: "<<data->satellites_used<<endl;
 cout<<"satellites_visible: "<<data->satellites_visible<<endl;
 if (isfinite(data->fix.latitude) &&
            isfinite(data->fix.longitude)) {
            // Display data from the GPS receiver if valid.
            printf("Lat %.9f Lon %.9f\n",
                   data->fix.latitude, data->fix.longitude);
        } else {
            printf("Lat n/a Lon n/a\n");
        }
 printf("jamInd: %d\n",data->fix.jam);
 cout<<"-------------------------------------"<<endl;


}

int main(void)
{
    gpsmm gps_rec("localhost", DEFAULT_GPSD_PORT);

    if (gps_rec.stream(WATCH_ENABLE|WATCH_JSON) == NULL) {
        cerr << "No GPSD running.\n";
        return 1;
    }

    for (;;) {
        struct gps_data_t* newdata;

        if (!gps_rec.waiting(50000000))
          continue;

        if ((newdata = gps_rec.read()) == NULL) {
            cerr << "Read error.\n";
            return 1;
        } else {
            showGPSData(newdata);
        }
    }
    return 0;
}

If someone can give me a idea of why my code doesn't display the correct lat,lon, and satellite information
it would be much appreciated.

Also one other question: How do we access the JSON in a client program?

Thanks
Thomas





From: gpsd-users-bounces+tgiglia=hotmail.com@nongnu.org on behalf of Gary E. Miller
Sent: Monday, March 18, 2024 8:06 PM
To: gpsd-users@nongnu.org
Subject: Re: How do you access UBX MON-HW messages in a gpsd client

Yo Thomas!

On Mon, 18 Mar 2024 23:35:03 +0000
Thomas Giglia <tgiglia@hotmail.com> wrote:

> Bottom line. My source looks like it came from a tarball I installed
> several months ago.

Regardless of when it was installed, that source is a lot older than
that.

Since the patches are a day old, no good for the present purposes.

> Created a new repos and cloned from git.
> Build and install completed successfully and according to the
> documentation.

Good.
 
> I will test the new "jam" field tomorrow.

Well, since you are ready to test, I took anouther look at the code,
and I see "jam" was not coming out in the JSON.  Ugly.  UBX is supposed
to start the data from every epoch with a UBX-NAV-PVT, and end every
epoch with a UBX-NAV-EOE.  Sadly, NAV-HW and NAV-RF are sent AFTER the
NAV-EOE.  So the cycle ender finds the NAV-HW too late for the current
epoch, and too soon for the next epoch.

I will have to sleep on this one before I come up with a good fix.

You can still starta the new gpsd with "-nND 5" and see the jamInd in
the log output.  You will no longer need to enable the MON-HW.

RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
        gem@rellim.com  Tel:+1 541 382 8588

            Veritas liberabit vos. -- Quid est veritas?
    "If you can't measure it, you can't improve it." - Lord Kelvin

reply via email to

[Prev in Thread] Current Thread [Next in Thread]