gpsd-users
[Top][All Lists]
Advanced

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

Re: Gpsd information showing as nan in application


From: raaj lokanathan
Subject: Re: Gpsd information showing as nan in application
Date: Wed, 25 Mar 2020 17:24:50 +0800

Hi Gary,


Just would like to know the NAN is it something expected from gpsd? Why is it getting NAN values?

On Tue, 24 Mar 2020 at 2:27 AM, Gary E. Miller <address@hidden> wrote:
Yo raaj!

On Mon, 23 Mar 2020 11:21:48 +0800
raaj lokanathan <address@hidden> wrote:

> I have written a sample application in cpp which uses the libgps to
> read the gps info from gpsd.

Did you use one of the gpsd clients as a guide?

> Currently it's able to read however only a few times it's working.
> Most of the time it shows as 'nan' and I have to run another few
> times my application in order to get for example the one latitude,
> longitude and altitude again.

Normal.  Not evey JSON message from gpsd contains every data item.  Some
just describe the sky view, some the PVT state.  Did you compare your
output to the output of cgps at the same time?

gpsd sets all unknown floating point data items to NAN to indicate they
are unknown.  Look at the sample clients, like cpgs, to see how to
handle NANs.

For example, you display the Longitude this way:


         if (gpsdata->fix.mode >= MODE_3D) {
                 altitude = gpsdata->fix.altMSL;
         }

You failed to check either the LATLON_SET bit or for NAN.  So you may
be trying to print the (non-existent) altMSL from a SKY message.

But cgps does it this way:

    if (gpsdata->fix.mode >= MODE_3D) {
        [...]
        if (0 != isfinite(gpsdata->fix.altMSL))
            (void)snprintf(buf2, sizeof(buf2), "%11.3f ",
                           gpsdata->fix.altMSL * altfactor);
        else
            (void)strlcpy(buf2, "       n/a ", sizeof(buf2));

Spend some quality time reading the existing code.

> Attached is my cpp code in txt format.

But you forgot the hpp file, and how you build it.

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

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

Raaj Lokanathan

reply via email to

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