Menu

#8 incorrect number of satellites in use

open
nobody
None
5
2015-06-05
2007-12-17
Anonymous
No

I have been getting an incorrect number of satellites in use from nmealib. I am guessing the cause is that I am using the parser in a different way than may have been tested. In the current code, when a GPGSA sentence is parsed, you are comparing each of the PRNs in the sentence against the PRNs already stored for each of the satellites. This setup assumes that a set of GPGSV sentences have been received BEFORE the GPGSA sentence. However, my GPS unit sends a chunk of sentences once a second in this order: GPGGA, GPGSA, GPGSV, GPRMC. I am creating a new parser for each chunk of data - because I want the data in each chunk to be independent of those around it. Therefore I never get GPGSV before GPGSA and I always get 0 satellites in use because none of the PRNs will match empty satellite data!

I guess if you kept using the same parser continuously, then inuse would only be terribly wrong for the first chunk of data. However, each subsequent time it would still be comparing the PRNs from a _new_ GPGSA sentence against the PRNs from the _previous_ set of GPGSV sentences.

So, I'm confused by the way you are implementing the count of number of satellites in use. Is there a reason you need to compare the PRNs against those in the satellite list? Why not just count the number of PRNs in the GPGSA sentence and call that the total the number of satellites in use? Or, why not use the field directly from the GPGGA sentence?

Suggested fix in parse.c, nmea_GPGSA2info(). Just count the number of non-zero satellite PRNs in the sentence to get the total number of satellites in use. (NOTE: There is still another problem with the in_use flag relying on old GPGSV sentences. This will probably require a little more effort to fix.)

for(i = 0; i < NMEA_MAXSAT; ++i)
{
if (pack->sat_prn[i] != 0) {
nuse++;
}
for(j = 0; j < info->satinfo.inview; ++j)
{
if(pack->sat_prn[i] && pack->sat_prn[i] == info-> satinfo.sat[j].id)
{
info->satinfo.sat[j].in_use = 1;
//nuse++;
}
}
}

Discussion

  • gondolier

    gondolier - 2007-12-17

    Logged In: YES
    user_id=1961891
    Originator: NO

    This was submitted by gondolier

     
  • Ferry Huberts

    Ferry Huberts - 2011-02-24

    can you clone from https://github.com/fhuberts/nmealib and supply a patch?

     
  • Ferry Huberts

    Ferry Huberts - 2015-06-05
    Post awaiting moderation.

Log in to post a comment.