我做过,很简单,用MSCOMM控件后CFile类读取GPS传到串口的数据,你要得定位信息在$GPRMC行中。你也可以用超级终端来读串口数据。然后研究一下,看你到底需要那一部分数据。

解决方案 »

  1.   

    我有一些源码,你需要的话可以mail给你!
      

  2.   

    多谢各位的帮助  
    我现在急需这方面的原理,code,
    有知道的请帮兄弟一把
    email [email protected] 大侠用的是什么档次的GPS,贵不贵 ?
      

  3.   

    sorry
    上次一时手快,只写的默认的50分,
    我一定多多加分,感谢回复的朋友们
      

  4.   

    m_strstr=(CString)m_mscomm.GetInput().bstrVal;
    int i,j;
    i=m_strstr.Find("$GPRMC");
    m_strmsg=m_strstr.Mid(i,100);
    i=m_strmsg.Find(",A");
    if(i!=-1)
    {
      x1=::atof(m_strmsg.Mid(i+15,10).Left(3));
      x2=::atof(m_strmsg.Mid(i+15,10).Mid(3,2));
      x3=::atof(m_strmsg.Mid(i+15,10).Right(4));
      x=x1+(x2+x3/10000)/60; 
      x1=::atof(m_strmsg.Mid(i+3,9).Left(2));
      x2=::atof(m_strmsg.Mid(i+3,9).Mid(2,2));
      x3=::atof(m_strmsg.Mid(i+3,9).Right(4));
      y=x1+(x2+x3/10000)/60;
      int hh=::atoi(m_strmsg.Mid(7,2))+8;
      if(hh>=24) hh-=24;
         int mm=::atoi(m_strmsg.Mid(9,2));
         int ss=::atoi(m_strmsg.Mid(11,2));
         j=m_strmsg.Find(",*");
         m_strmsg=m_strmsg.Mid(i+28,j-i-28);
         i=m_strmsg.Find(',');
         j=m_strmsg.GetLength();
         speed=::atof(m_strmsg.Left(i));
         speed*=1.852;   //把速度从节转换为km/h
         m_strmsg=m_strmsg.Right(j-i-1);
         j=m_strmsg.GetLength();
         i=m_strmsg.Find(',');
         degree=::atoi(m_strmsg.Left(i));
         m_strmsg=m_strmsg.Right(j-i-1);
        if(degree>180) degree-=180;
           if(degree<15||degree>=165) fg=0;
           else if(degree<45) fg=1;
           else if(degree<75) fg=2;
           else if(degree<105) fg=3;
           else if(degree<135) fg=4;
           else fg=5;
       m_pSet->AddNew();
       m_pSet->m_column1="20"+m_strmsg.Mid(4,2)+"-"+
       m_strmsg.Mid(2,2)+"-"+m_strmsg.Left(2);
       m_pSet->m_column2.Format("%02d:%02d:%02d",hh,mm,ss);
       m_pSet->m_column3.Format("%f",x);
       m_pSet->m_column4.Format("%f",y);
       m_pSet->m_column5.Format("%1d",fg);
       m_pSet->m_column6.Format("%.2f",speed);
       m_pSet->Update();
       m_pSet->MoveFirst();
       m_strmsg.Format("位置: 经度:%f,纬度:%f 速度: %.2f 公里/小时",x,y,speed);
    }
      

  5.   

    To ivefire,你是不是用的GPS模块,怎么和我做的如此的像。
      

  6.   

    Thank ivefire,!
    thank dutsf!
    Thank all !!
    btw ,谁能介绍一下GPS硬件方面的信息?
    象型号,价格什么的?
      

  7.   

    there are a lot of gps related products, such as jupiter, novatel,marconi,ashtech,argo. the simplest gps oem card is about 50$
      

  8.   

    where can find these detail information ?
    Please tell me.
    anyway, thanks all !