2023-01-27 10:04 PM
I'm using ST's X-CUBE-GNSS1 software pack but it only prints the minute part of my location coordinate
Compared with the actual coordinate that shows the degree and seconds part
Here's the software pack code that correspond with the above output
void GNSS_DATA_GetGPRMCInfo(GNSSParser_Data_t *pGNSSParser_Data)
{
PRINT_INFO("\r\n");
(void)snprintf((char *)msg, MSG_SZ, "UTC:\t\t\t\t[ %02d:%02d:%02d ]\n\r",
pGNSSParser_Data->gprmc_data.utc.hh,
pGNSSParser_Data->gprmc_data.utc.mm,
pGNSSParser_Data->gprmc_data.utc.ss);
PRINT_INFO((char *)msg);
(void)snprintf((char *)msg, MSG_SZ, "Status:\t\t\t\t[ %c ]\t\t",
pGNSSParser_Data->gprmc_data.status);
PRINT_INFO((char *)msg);
if (pGNSSParser_Data->gprmc_data.status == (uint8_t)'A')
{
PRINT_INFO("-- Valid (reported in 2D and 3D fix conditions)\n\r");
}
else if (pGNSSParser_Data->gprmc_data.status == (uint8_t)'V')
{
PRINT_INFO("-- Warning (reported in NO FIX conditions)\n\r");
}
else
{
PRINT_INFO("-- Unknown status\n\r");
}
float64_t lat_mod = fmod(pGNSSParser_Data->gprmc_data.xyz.lat, 100.0);
float64_t lon_mod = fmod(pGNSSParser_Data->gprmc_data.xyz.lon, 100.0);
(void)snprintf((char *)msg, MSG_SZ, "Latitude:\t\t\t[ %f' %02d'' %c ]\n\r",
(pGNSSParser_Data->gprmc_data.xyz.lat - lat_mod) / 100.0,
(int16_t)lat_mod,
pGNSSParser_Data->gprmc_data.xyz.ns);
PRINT_INFO((char *)msg);
(void)snprintf((char *)msg, MSG_SZ, "Longitude:\t\t\t[ %f' %02d'' %c ]\n\r",
(pGNSSParser_Data->gprmc_data.xyz.lon - lon_mod) / 100.0,
(int16_t)lon_mod,
pGNSSParser_Data->gprmc_data.xyz.ew);
PRINT_INFO((char *)msg);
(void)snprintf((char *)msg, MSG_SZ, "Speed over ground (knots):\t[ %.01f ]\n\r",
pGNSSParser_Data->gprmc_data.speed);
PRINT_INFO((char *)msg);
(void)snprintf((char *)msg, MSG_SZ, "Trackgood:\t\t\t[ %.01f ]\n\r",
pGNSSParser_Data->gprmc_data.trackgood);
PRINT_INFO((char *)msg);
/*
(void)snprintf((char *)msg, MSG_SZ, "Date (ddmmyy):\t\t\t[ %ld ]\n\r",
pGNSSParser_Data->gprmc_data.date);
*/ /* Replaced by the following implementation for compatibility with AC6 and gcc compilers */
(void)snprintf((char *)msg, MSG_SZ, "Date (ddmmyy):\t\t\t[ %02d%02d%02d ]\n\r",
(int16_t)((pGNSSParser_Data->gprmc_data.date/10000)),
(int16_t)((pGNSSParser_Data->gprmc_data.date/100) - (100*(pGNSSParser_Data->gprmc_data.date/10000))),
(int16_t)(pGNSSParser_Data->gprmc_data.date - (100*(pGNSSParser_Data->gprmc_data.date/100))));
PRINT_INFO((char *)msg);
(void)snprintf((char *)msg, MSG_SZ, "Magnetic Variation:\t\t[ %.01f ]\n\r",
pGNSSParser_Data->gprmc_data.mag_var);
PRINT_INFO((char *)msg);
if ((pGNSSParser_Data->gprmc_data.mag_var_dir != (uint8_t)'E') &&
(pGNSSParser_Data->gprmc_data.mag_var_dir != (uint8_t)'W')) {
(void)snprintf((char *)msg, MSG_SZ, "Magnetic Var. Direction:\t[ - ]\n\r");
}
else {
(void)snprintf((char *)msg, MSG_SZ, "Magnetic Var. Direction:\t[ %c ]\n\r",
pGNSSParser_Data->gprmc_data.mag_var_dir);
}
PRINT_INFO((char *)msg);
PRINT_INFO("\n\n\r>");
return;
}
How do I print the other two components of the coordinate?
Solved! Go to Solution.
2023-01-28 01:35 AM
You probably don't have enabled printing of float. Search this forum or internet (-u _printf_float).
JW
2023-01-28 01:35 AM
You probably don't have enabled printing of float. Search this forum or internet (-u _printf_float).
JW
2023-01-28 03:06 AM
Woops! totally forgot about that. Thanks!