Enabling/disabling NMEA sentences on u-Blox gps receiver?

Without knowing much about how you're dealing with the incoming data, but if it's overflowing then its probably because the previous/current data is or has not been dealt with in a timely fashion.

With ublox7's; NEMA sentences are enabled via:

$PUBX,40,msgType,0,1,0,0*checksum

and disabled via:

$PUBX,40,msgType,0,0,0,0*checksum

You have 6 variables after the msgType whereas only 4 are expected. Other modules may require 6.

Checksum is calculated by XOR'ing all characters between the $ and the *, and is a 2 char HEX value.

eg;

// test string
const char *msg = "PUBX,40,GSV,0,0,0,0";

// find checksum
int checksum = 0;
for (int i = 0; msg[i]; i++)
    checksum ^= (unsigned char)msg[i];

// convert and create checksum HEX string
char checkTmp[8];
snprintf(checkTmp, sizeof(checkTmp)-1, F("*%.2X"), checksum);

// send to module
module.print("$");
module.print(msg);
module.println(checkTmp);

and to put this in to something [re]usable:

inline int calculateChecksum (const char *msg)
{
    int checksum = 0;
    for (int i = 0; msg[i] && i < 32; i++)
        checksum ^= (unsigned char)msg[i];

    return checksum;
}

INLINE int nemaMsgSend (const char *msg)
{
    char checksum[8];
    snprintf(checksum, sizeof(checksum)-1, F("*%.2X"), calculateChecksum(msg));
    module.print("$");
    module.print(msg);
    module.println(checksum);
}

inline int nemaMsgDisable (const char *nema)
{
    if (strlen(nema) != 3) return 0;

    char tmp[32];
    snprintf(tmp, sizeof(tmp)-1, F("PUBX,40,%s,0,0,0,0"), nema);
    //snprintf(tmp, sizeof(tmp)-1, F("PUBX,40,%s,0,0,0,0,0,0"), nema);
    nemaMsgSend(tmp);

    return 1;
}

inline int nemaMsgEnable (const char *nema)
{
    if (strlen(nema) != 3) return 0;

    char tmp[32];
    snprintf(tmp, sizeof(tmp)-1, F("PUBX,40,%s,0,1,0,0"), nema);
    //snprintf(tmp, sizeof(tmp)-1, F("PUBX,40,%s,0,1,0,0,0,0"), nema);
    nemaMsgSend(tmp);

    return 1;
}

and then to disable a message:

nemaMsgDisable("GSV");

to enable a message:

nemaMsgEnable("GSV");

Hope this helps.

Michael

Tags:

Nmea