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 };
