Chinaunix首页 | 论坛 | 博客
  • 博客访问: 541317
  • 博文数量: 150
  • 博客积分: 5010
  • 博客等级: 大校
  • 技术积分: 1861
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-17 00:19
文章分类

全部博文(150)

文章存档

2011年(1)

2009年(14)

2008年(135)

我的朋友

分类: LINUX

2008-09-28 14:56:46

最终的代码,我写的就是注释掉的,一开始没加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) |
给主人留下些什么吧!~~