最终的代码,我写的就是注释掉的,一开始没加break,会产生重复的信息存在下一个数组中。并且每来一个信息都要比较也比较费时,而通过解析信息的,第9位,也就是消息是第几条,放在不同的数组中,这样不会重复。这是梁老师的advice .谢谢他
static void add_NMEAListener(UINT8* message, UINT16 messageLength)
{
char number;
if (message != NULL)
{
printf("Obtain message is %s", message);
if(strstr( message,"GPGSV" )!= NULL)// have satellite information
{
strncpy( &number, message+9, 1);
printf(" array number is %c \n",number);
if( number == '1' ){
printf("put into message_save[0]\n");
strcpy( message_save[0],message);
}
else if( number == '2' ){
printf(" put into messsage_save[1]\n");
strcpy( message_save[1],message);
}
else if( number == '3'){
printf( "put into message_save[2]\n " );
strcpy( message_save[2],message);
}
else{
printf( "invalid message\n");
}
/*
int i=0;
do
{
if( strcmp( message,message_save[i]))// compare to avoid repeating
{
strcpy( message_save[message_counter],message);
message_counter++;
}
else
{
break;
}
}while( i++
if(message_counter==3){
message_counter=0;
}*/
}
}
}
|
阅读(1208) | 评论(0) | 转发(0) |