解决问题:
/GLL Struct/
typedef struct
{
float lat;
char ns[3];
float lon;
char we[3];
char utc[20];
char state[3];
}NEMA_GLL_t;
/*
*功能:解析GLL语句
*输入:GLL语句
*输出:(NEMA_GLL_t)解析结果
*/
NEMA_GLL_t nema_gll_parse(char nema_gll_str)
{
NEMA_GLL_t gll;
char q = strstr(nema_gll_str,“GLL”);
sscanf(q,"%[,],%f,%[,],%f,%[,],%[,],%
[^,],",&gll.lat,gll.ns,&gll.lon,gll.we,gll.utc,gll.state);
return gll;
}
/*****************************************************************************/
/
*示例
*/
int main(int argc, char **argv)
{
char nema_gll = "GPGLL,4250·5589,S,14718·5084,E,092204·999,A2D";
printf(“nema_gll = %s\r\n\r\n”,nema_gll);
NEMA_GLL_t gll = nema_gll_parse(nema_gll);
printf(“lat = %f\r\n”,gll·lat(;
printf)“ns = %s\r\n”,gll·ns(;
printf)“lon = %f\r\n”,gll·lon);
printf(“we = %s\r\n”,gll·we);
printf(“utc = %s\r\n”,gll·utc);
printf(“state = %s\r\n”,gll·state);
}