Today I do use the Neo M8n GPS receiver. I was not happy with the Neo 6 and Neo 7 series as they only have a battery back-uped RAM and I kept loosing data no matter what. And I did not wanted to initialize the device at each start up.
So the NEO-M8n uses a flash RAM. I do Programm the GPS with the configuration SW provided by U-blox (U-Center).
Using a NEMA protocol as the output standard would make you use a NEMA protocol parser to filter out the desired data. A parser is needed because the amount of data transmitted can vary.
I did turn off the NEMA protocol and only use U-blox’s own UBX protocoll. Because the amount of bytes in this protocoll is fix (thx U-blox ;-)), you can simply pick the bytes at a given position to retrieve your information. Easy.
POSLLH uses 28bytes and VELNED uses 36bytes. Latitude, longitude, altitude, heading and ground velocity is available.
Here’s the code:
/***********************************************************************************
* The gps data received by the UART are stored away. We use a NEO-M8n from ublock
* with NEMA protocol turned off. Instead the ublock protocol UBX is used to get
* well defined number of bytes that can be read
***********************************************************************************/
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
if (huart->Instance == UART4)
{
parseFlightMonitorData();
}
if (huart->Instance == UART5)
{
latitude[0] = GPS_BUF[14];
latitude[1] = GPS_BUF[15];
latitude[2] = GPS_BUF[16];
latitude[3] = GPS_BUF[17];
longitude[0] = GPS_BUF[10];
longitude[1] = GPS_BUF[11];
longitude[2] = GPS_BUF[12];
longitude[3] = GPS_BUF[13];
hMSLGPS[0] = GPS_BUF[22];
hMSLGPS[1] = GPS_BUF[23];
hMSLGPS[2] = GPS_BUF[24];
hMSLGPS[3] = GPS_BUF[25];
groundSpeedGPS[0] = GPS_BUF[60];
groundSpeedGPS[1] = GPS_BUF[61];
groundSpeedGPS[2] = GPS_BUF[62];
groundSpeedGPS[3] = GPS_BUF[63];
headingGPS[0] = GPS_BUF[64];
headingGPS[1] = GPS_BUF[65];
headingGPS[2] = GPS_BUF[66];
headingGPS[3] = GPS_BUF[67];
gpsDataReady = SET;
}
}