6

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.

3
  • 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, 2016 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, 2016 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, 2016 at 14:08

3 Answers 3

5

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

5
  • 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, 2016 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, 2016 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, 2016 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, 2016 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, 2018 at 12:00
1

The probable reason that you are having to use soft serial is that the processor you are using only has one USART which is used both for the USB port on the board and the TTL serial port if you try and use them both at the same time there is a conflict. Solution unplug your serial port cable or TTL connection. Here are some useful strings to help you with the problems some of you are having.

//U blox NMEA 6 Some command strings in Hex
//b5 62 06 01 08 00 f0 00 01 01 01 01 01 01 05 38 b5 62 06 01 02 00 f0 00 f9 11  GAA  ON                                                                                                                                     
//b5 62 06 01 08 00 f0 00 00 00 00 00 00 01 00 24 b5 62 06 01 02 00 f0 00 f9 11  GGA OFF
//b5 62 06 01 08 00 f0 01 01 01 01 01 01 01 06 3f b5 62 06 01 02 00 f0 01 fa 12  GLL ON                                                                                                                                      
//b5 62 06 01 08 00 f0 01 00 00 00 00 00 01 01 2b b5 62 06 01 02 00 f0 01 fa 12  GLL OFF
//b5 62 06 01 08 00 f0 02 01 01 01 01 01 01 07 46 b5 62 06 01 02 00 f0 02 fb 13  GSA ON                                                                                                                                      
//b5 62 06 01 08 00 f0 02 00 00 00 00 00 01 02 32 b5 62 06 01 02 00 f0 02 fb 13  GSA OFF
//b5 62 06 01 08 00 f0 03 01 01 01 01 01 01 08 4d b5 62 06 01 02 00 f0 03 fc 14  GSV ON                                                                                                                                       
//b5 62 06 01 08 00 f0 03 00 00 00 00 00 01 03 39 b5 62 06 01 02 00 f0 03 fc 14  GSV OFF
//b5 62 06 01 08 00 f0 04 01 01 01 01 01 01 09 54 b5 62 06 01 02 00 f0 04 fd 15  RMC ON                                                                                                                                        
//b5 62 06 01 08 00 f0 04 00 00 00 00 00 01 04 40 b5 62 06 01 02 00 f0 04 fd 15  RMC OFF
//b5 62 06 01 08 00 f0 05 01 01 01 01 01 01 0a 5b b5 62 06 01 02 00 f0 05 fe 16  VTG ON                                                                                                                                       
//b5 62 06 01 08 00 f0 05 00 00 00 00 00 01 05 47 b5 62 06 01 02 00 f0 05 fe 16  VTG OFF
//Set 6 to output one message every 10 seconds
//b5 62 06 08 06 00 10 27 01 00 01 00 4d dd b5 62 06 08 00 00 0e 30
//Save 6 current configuration to Battery Backed Ram or Flash
// 62 06 09 0d 00 00 00 00 00 ff ff 00 00 00 00 00 00 03 1d ab b5 62 0a 04 00 00 0e 34      
// Send strings using a serial port

void setup() {
 Serial.begin(9600);
// Example to turn GGA message off
//b5 62 06 01 08 00 f0 00 00 00 00 00 00 01 00 24 b5 62 06 01 02 00 f0 00 f9 11  GGA OFF

byte message[] = {0xb5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xf0, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x01, 0x00, 0x24, 0xb5, 0x62, 0x06, 0x01,0x02, 0x00, 0xf0, 0x00, 0xf9, 0x11 };

Serial.write(message, sizeof(message));     
}    
void loop() {
  // put your main code here, to run repeatedly:    
} 
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 and acknowledge you have read our privacy policy.

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