5

I want to disable the $GPGSV sentences on u-Blox NEO-7M because I have serial buffer overflow on Arduino. I found in the Receiver Discription p.69 and tried sending this:

$PUBX,40,GSV,0,0,0,0,0,0*59

But the receiver keeps sending the $GPGSV.

  • The manual says the checksum is *5D and not 59. Could this be the reason? Did you try using the software ucenter from uBlox? – Techie_Gus Jun 17 '16 at 12:31
  • Yes, i tried ucenter but did not found anything. I changed values, so the checksum is different. I used this website to calculate the checksum. – MatMis Jun 17 '16 at 12:43
  • I'm afraid I can't be of help to you. It's been a while I haven't fiddled with these things. – Techie_Gus Jun 18 '16 at 14:08
3

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

  • Welcome to GIS SE! As a new user be sure to take the Tour to learn about our focussed Q&A format. It's great that you have included code in your answer, but can you add a paragraph or so explaining how that code answers the question, please? – PolyGeo Jul 9 '16 at 1:41
  • I have an error with your code :s SerialEvent:44: error: cannot convert 'const __FlashStringHelper*' to 'const char*' for argument '3' to 'int snprintf(char*, size_t, const char*, ...)' snprintf(checkTmp, sizeof(checkTmp)-1, F("*%.2X"), checksum); – MatMis Jul 22 '16 at 16:18
  • I got it working when I replaced F("*%.2X") with "*%.2X" but have still no idea how that line of code works – MatMis Jul 22 '16 at 16:59
  • F() is a string macro which instructs the compiler how the string is to be stored, as detailed here: arduino.cc/en/Reference/PROGMEM – Okio Jul 23 '16 at 19:26
  • Just want to point out that I had to use $PUBX,40,msgType,0,0,0,1*checksum to re-enable a msgType (see the location of the 1). Thanks for the great answer! – Daniel F Oct 11 '18 at 12:00
0

I found that if you use the hardware serial from arduino that you can not configure the receiver with u-center. It works with softwareSerial. If someone knows why, please let me know. :)

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  //mySerial.println("Hello, world?");
}

void loop() { // run over and over
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.