M8N GPS set update rate

Hi Guys!

On most of fake M8N there is no EEPROM, so i cannot save the update rate permanent.
So i need to set the update on every start with UBX commands trough Arduino Mega 2560 hardware Serial 2
I got this code:

#include <NMEAGPS.h>
#include <GPSport.h>

const unsigned char ubxRate5Hz[] PROGMEM = { 0x06,0x08,0x06,0x00,200,0x00,0x01,0x00,0x01,0x00 };
const char baud38400 [] PROGMEM = "PUBX,41,1,3,3,38400,0";

static NMEAGPS  gps;

void setup() {
  gpsPort.begin(9600);
  delay( 100 );
  gps.send_P( &gpsPort, (const __FlashStringHelper *) baud38400 );
  gpsPort.flush();                              // wait for the command to go out
  delay( 1000 );                                  // wait for the GPS device to change speeds
  gpsPort.end();                                // empty the input buffer, too
  gpsPort.begin( 38400 ); 
  delay( 100 );
  sendUBX( ubxRate5Hz, sizeof(ubxRate5Hz) );
}

void sendUBX( const unsigned char *progmemBytes, size_t len )
{
  gpsPort.write( 0xB5 ); // SYNC1
  gpsPort.write( 0x62 ); // SYNC2

  uint8_t a = 0, b = 0;
  while (len-- > 0) {
    uint8_t c = pgm_read_byte( progmemBytes++ );
    a += c;
    b += a;
    gpsPort.write( c );
  }

  gpsPort.write( a ); // CHECKSUM A
  gpsPort.write( b ); // CHECKSUM B

}

Sometimes it's work fine, sometimes not.
I debug it with comment out lines, and figured out, that the program frooze at the "gpsPort.begin( 38400 ); " line

what is causing the problem?

If i don't need 5Hz, then how can i set to 2Hz?
Wich hex data i need to change?

const unsigned char ubxRate5Hz[] PROGMEM = { 0x06,0x08,0x06,0x00,200,0x00,0x01,0x00,0x01,0x00 };

The M8N is a module that uses a Ublox M8 GPS inside.

Not sure if there is a 'geniune' manufacturer of that particular module and its not required for the GPS to operate to include the EEPROM or even the battery.

One sympton of fake Ublox GPSs I have noted is that they dont accept some configuration commands.

If you want help with code, you need to post code that at least compiles ..................

I changed the code in main post...
I am using NEOGps libraray for that

Strange, that sometime its work, sometimes its not...
Need to wait more before gpsPort.begin( 38400 ); ?

Maybe i can use 2Hz refresh rate, in this case maybe baud 9600 will be enough, so i don't need to change the baud (where my program frooze)

But how can i send 2Hz command?

In this picture there is a sample for 1,5,10,16 Hz

1 Hz = 1000 ms
5 Hz = 200 ms
10 Hz = 100 ms
16 Hz = 50 ms

But how 0xE8, 0x03 will be 1000?
And how can i set it to 500?
If i write "500, 0x00" then its not working

What is HEX 0x3E8 in decimal ?

If i write "500, 0x00" then its not working

A char can only be 0 to 255 ...............................

ohhh.. so:

500 = 0xF4, 0x01 ???

Probably, the details on the format for the commands will be in the datasheet for the GPS or the U-center tool that Ublox provide for configuring GPSs.