binary protocol

Hello everyone. I'm work with NEO-M8N GPS and it is not clear to me how I make a binary message?

For example, in various gitHub pages I can see that for enable the message "NAV-VELNED" the binary code is:
0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0x01, 0x12, x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x23, 0x2E.

As for turn off "NAV-VELNED", we need write:
0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0x01, 0x12, 0x00, 0x00, 0x00, x00, 0x00, 0x00, 0x22, 0x29,

I can't associate this message with the Neo-m8n manual = /

There is a manual?

Thanks.

The NEO-M8 hardware manual (the data sheet) is here.

The protocol descriptions are here.

The simplest way to configure the module is to download the free u-center control software.

Thanks for your reply jremington.

I already read these manuals, in fact that was my starting point. My problem is converting the message structure 0x5B 0x62 ...on page 401 of here.

If you can explain to me how, I thank you in advance and ask for patience with my ignorance.:sob:

I don't know what you mean by "converting the message structure".

If you could take a moment to clearly describe what you are trying to do, and what the problem is, perhaps I or someone else can help.

Are you confusing the HUMAN readable text with what the actual message should be?
Human = "0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0x01, 0x12, 0x00, 0x00, 0x00, x00, 0x00, 0x00, 0x22, 0x29,".
message text = B5620601080001120000000000002229.
Paul

Ok jremington and Paul_KD7HB.

I try explane my problem with a example.

Suppose I want to enable the NAV-VELNED protocol on my NEO-M8N. I know that, according to the UBX FRAME Structure, I have to

"0xB5, 0x62" refer to the HEADER
0x06, 0x01 refers to CFG-MSG
0x08, 0x00 length (for Set message rate (s))

0x01, 0x12, Class and ID

Then this part I don’t understand, how to indicate that I’m enabling NAV-VELNED

0x00, 0x00, 0x00, x00, 0x00, 0x00, 0x22, 0x29, ".

Thanks for the help in the discussion.

The beauty of using u-center is that you simply check boxes to enable/disable features and messages, then u-center will create the control message and send it to the GPS module. The setting is stored in non-volatile memory, and survives power cycles.

U-center will SHOW you the control message contents, so you can accomplish the same task using an Arduino.

If you insist on doing this the hard way, and figuring it all out by yourself, the information is buried in the UBX protocol documentation.

jremington:
The beauty of using u-center is that you simply check boxes to enable/disable features and messages, then u-center will create the control message and send it to the GPS module. The setting is stored in non-volatile memory, and survives power cycles.

U-center will SHOW you the control message contents, so you can accomplish the same task using an Arduino.

About U-center I agree with you, but I dont have a Windows. My laptop it is very old. cant run windows =/

jremington:
If you insist on doing this the hard way, and figuring it all out by yourself, the information is buried in the UBX protocol documentation.

I ask in this forum with the intention not only to solve the problem, but to understand and learn. So, therefore, I asked for help.
Thanks.

To "understand and learn", you simply have to read the documentation. There is a lot of it, and it is really a pain to wade through. Forum members are probably not going to do it for you.

You should ask yourself why it is important to learn such complex and obscure material, used by no other manufacturer, when a setup and configuration program like u-center is provided to do all the work for you.

jremington:
You should ask yourself why it is important to learn such complex and obscure material, used by no other manufacturer, when a setup and configuration program like u-center is provided to do all the work for you.

The u-center it is my first try, bu how I tell...

roneyd:
About U-center I agree with you, but I dont have a Windows. My laptop it is very old. cant run windows =/

I agree that learning obscure material is not a good choice, but if a user has a simple way of showing how I use binary code, my job can be made easier.
I Wait any person with time to explain for me. Thanks

What I do in my home-brew S-port GPS sensor for my modelairplanes is this:
I connect the GPS module to the hardware serial port.

First define the command strings that you want to send to the GPS.

//format hex command strings for sending to UBLOX
const static char velned[] = {0xb5, 0x62, 0x06, 0x01, 0x03, 0x00, 0x01, 0x12, 0x01, 0x1e, 0x67};
const static char posllh[] = {0xb5, 0x62, 0x06, 0x01, 0x03, 0x00, 0x01, 0x02, 0x01, 0x0e, 0x47};
const static char sol[] = {0xb5, 0x62, 0x06, 0x01, 0x08, 0x00, 0x01, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x17, 0xDa};
const static char airborne[] = {0xb5, 0x62, 0x06, 0x24, 0x24, 0x00, 0xff, 0xff, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10, 0x27,
                                0x00, 0x00, 0x05, 0x00, 0xfa, 0x00, 0xfa, 0x00, 0x64, 0x00, 0x2c, 0x01, 0x00, 0x3c, 0x00, 0x00,
                                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x0b, 0xb5, 0x62, 0x06, 0x24,
                                0x00, 0x00, 0x2a, 0x84
                               };
const static char rate_a[] = {0xb5, 0x62, 0x06, 0x08, 0x06, 0x00, 0x90, 0x01, 0x01, 0x00, 0x01, 0x00, 0xa7, 0x1f}; // 2.5 Hz
const static char rate_b[] = {0xb5, 0x62, 0x06, 0x08, 0x00, 0x00, 0x0e, 0x30}; // 2.5 Hz

Then in the setup section I first turn off all default messages, Then I set the GPS unit to "airborne 4G" mode, as using it in a model airplane gives a lot of sudden high-g turns. I increase the nav rate from 1Hz to 2.5Hz and then I activate the POSLLH, VELNED and SOL messages.

 delay (1000);  wait for the GPS to come to its senses.
Serial.begin(9600);

// First turn off the default NMEA messages that come out of the GPS module by default.
  delay(100);
  Serial.println(F("$PUBX,40,RMC,0,0,0,0*47")); //RMC OFF
  delay(100);
  Serial.println(F("$PUBX,40,VTG,0,0,0,0*5E")); //VTG OFF
  delay(100);
  Serial.println(F("$PUBX,40,GGA,0,0,0,0*5A")); //GGA OFF
  delay(100);
  Serial.println(F("$PUBX,40,GSA,0,0,0,0*4E")); //GSA OFF
  delay(100);
  Serial.println(F("$PUBX,40,GSV,0,0,0,0*59")); //GSV OFF
  delay(100);
  Serial.println(F("$PUBX,40,GLL,0,0,0,0*5C")); //GLL OFF
  delay(100);

//Now write the configuration commands to the GPS module
  Serial.write(airborne, sizeof(airborne)); //set GPS mode to airborne < 4g
  delay(100);
  Serial.write(rate_a, sizeof(rate_a)); //set GPS update rate to 2.5Hz (1st string)
  delay(100);
  Serial.write(rate_b, sizeof(rate_b)); //set GPS update rate to 2.5Hz (2nd string)
  delay(100);
  Serial.write(velned, sizeof(velned)); // VELNED (VELocity, North, East, Down) message ON
  delay(100);
  Serial.write(posllh, sizeof(posllh)); // POSLLH (POSition Latitude Longitude Height) message ON
  delay(100);
  Serial.write(sol, sizeof(sol)); // Navigation SOLution message ON
} // end setup

With this example you should be able to configure your module.

Hello
Thank you for sharing your solution. Looking at your example and buying with the manual, I see that the manual indicates that the code $PUBX,40,GLL,0,0,0,0,0,0 * 5D. But yours has two zeros less. These things that make me confused, do you understand?

  Serial.println(F("$PUBX,40,GLL,0,0,0,0*5C")); //GLL OFF

delay(100);

Thanks.

I expect the shorter message to be a message from an older firmware version. It turns off the NMEA messages only on the first 4 ports. The Ublox modules that I use accept the older message, so they must be backwards compatible.
These ports are turned off by the short message:
rddc = I2C
rus1 = UART1 (the one you use)
rus2 = UART2
rusb = USB

rspi = SPI is not touched. You would need the longer PUBX message for turning off also the SPI port.

Since you are only using the UART1 port of your module, the effect for you is the same whether you use the current (longer) version of the message or the obsolete (shorter) version.

Here are some nice examples: https://ukhas.org.uk/guides:ublox6#polling_the_module

hmeijdam:
I expect the shorter message to be a message from an older firmware version. It turns off the NMEA messages only on the first 4 ports. The Ublox modules that I use accept the older message, so they must be backwards compatible.
These ports are turned off by the short message:
rddc = I2C
rus1 = UART1 (the one you use)
rus2 = UART2
rusb = USB

rspi = SPI is not touched. You would need the longer PUBX message for turning off also the SPI port.

Since you are only using the UART1 port of your module, the effect for you is the same whether you use the current (longer) version of the message or the obsolete (shorter) version.

Here are some nice examples: https://ukhas.org.uk/guides:ublox6#polling_the_module

Perfect friend! That was exactly what I needed. Last night I managed to make the u-center work here on my old PC. As jremington said, he is friendly and handsome. Now I have mastery and understanding of what I am doing.

Should you want to create your own messages from the protocol manual, you need to calculate the checksum. I made this small sketch that does exactly that.

Copy whatever message you need in the sketch and run it.

(note that I left the checksum in the string at the end, so I could quickly check existing strings with a checksum already in it (copied out of U-centre). If you run the sketch and you do not know the checksum yet make the last two bytes 0x00 , 0x00 (or whatever you want, as the sketch ignores them anyway).

/*UBlox GPS message checksum calculator
  V1.0 by Hans Meijdam
 U-Blox checksum calculator.
 V1.1 Hans Meijdam, March 2021
  This sketch will calculate the UBLOX checksum. The checksum algorithm used is the 8-Bit Fletcher Algorithm, which is used in the TCP standard (RFC 1145).
  leave out the first two sync-char of the UBLOX sentence and the last two bytes are the checksum bytes.

  expected outcome of the below example should be: CK_A = 91 and CK_B = 84
*/
const static uint8_t myStr[] PROGMEM = {0xB5, 0x62, 0x06, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0xD0, 0x08, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,  0x91, 0x84};
//                                      ====sync=== ============================================== checksum calculated over these bytes ===========================================================  =checksum=

void setup() {
  Serial.begin(9600);
  uint8_t CK_A = 0;
  uint8_t CK_B = 0;
  uint8_t i;

  for (i = 0; i < sizeof(myStr) - 4; i++) { // "-4" because leave the first two and the last two bytes out of the checksum calculation.
    CK_A = CK_A + pgm_read_byte(&myStr[i + 2]); // "+2" because we skip the first 2 sync bytes
    CK_B = CK_B + CK_A;
  }
  Serial.print(" CK_A = ");
  Serial.print(CK_A, HEX);
  Serial.print(" and CK_B = ");
  Serial.println(CK_B, HEX);
}

void loop() {
}

Last night I managed to make the u-center work here on my old PC.

That is good to hear!

U-center was originally written for UBlox employees to use, because they did not want to have to wade through the documentation either.

hmeijdam:
Should you want to create your own messages from the protocol manual...

Very nice

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.