Exemplo n.º 1
0
/************************************************************************
* 函数名:	GPSDataParser
* 描  述:	解析NEMA-0183协议数据
* 入  参:
* 出  参: 
* 返  回: 
* 备  注:	一秒钟接收一次
单BD2(热启动)$CCSIR,1,0*49<CR><LF>
$BDRMC,075654.00,A,3109.731130,N,12123.330827,E,0.0,,250413,,,A*67
$BDGGA,075654.00,3109.731130,N,12123.330827,E,1,07,4.3,86.7,M,8.0,M,,,2.5*7E
$BDGLL,3109.731130,N,12123.330827,E,075654.00,A,0*0E
$BDGSA,A,3,06,13,08,01,09,11,03,,,,,,5.0,4.3,2.5,3.6*26
$BDGSV,2,1,7,06,02,191,25,13,10,202,33,08,58,185,26,01,49,145,32*55
$BDGSV,2,2,7,09,09,216,24,11,57,111,25,03,53,200,32*6E

单GPS(热启动)$CCSIR,2,0*4A<CR><LF> 
$GPRMC,075819.00,A,3109.717233,N,12123.341973,E,0.0,,250413,,,A*73
$GPGGA,075819.00,3109.717233,N,12123.341973,E,1,07,1.0,66.7,M,8.0,M,,,2.1*66
$GPGLL,3109.717233,N,12123.341973,E,075819.00,A,0*1A
$GPGSA,A,3,03,06,14,21,23,32,19,,,,,,2.3,1.0,2.1,0.9*31
$GPGSV,2,1,8,03,25,199,41,06,41,183,41,14,17,151,38,21,06,103,31*46
$GPGSV,2,2,8,23,25,316,33,32,21,243,35,19,02,198,41,30,66,344,26*49

BD2/GPS双模(热启动)$CCSIR,3,0*4B<CR><LF> 
$GNRMC,075955.00,A,3109.716702,N,12123.342782,E,0.0,,250413,,,A*61
$GNGGA,075955.00,3109.716702,N,12123.342782,E,1,15,0.9,62.9,M,8.0,M,,,0.9*7F
$GNGLL,3109.716702,N,12123.342782,E,075955.00,A,0*08
$GPGSA,A,3,03,06,14,21,23,19,16,32,,,,,1.3,0.9,0.9,0.7*39
$BDGSA,A,3,06,13,08,01,09,11,03,,,,,,1.3,0.9,0.9,0.7*23
$GPGSV,3,1,9,03,25,199,39,06,42,183,41,14,17,151,39,21,06,102,33*48
$GPGSV,3,2,9,23,26,316,24,19,03,198,40,30,65,346,21,16,59,276,12*40
$GPGSV,3,3,9,32,21,242,14*73
$BDGSV,2,1,7,06,01,191,21,13,09,201,35,08,58,186,26,01,49,145,32*5C
$BDGSV,2,2,7,09,09,216,22,11,57,108,16,03,53,200,32*60
************************************************************************/
void CPosData::PosDataParser(PCSTR pcPosData, DWORD dwLen)
{
	CLogTool::Instance()->WriteLogFile(pcPosData);

	if(NULL == g_pPosInfo)
		return;

	PCSTR pcHead	= NULL;
	PCSTR pcSection	= NULL;

	char* pcSectionRMC = NULL;
	char* pcSectionGGA = NULL;
	char* pcSectionGSA = NULL;
	char* pcSectionGSV = NULL;

	pcHead = strstr(pcPosData, MODE_GP DATA_RMC);
	if (pcHead == NULL)
	{
		return;
	}

	pcSectionRMC	= MODE_GP DATA_RMC;
	pcSectionGGA	= MODE_GP DATA_GGA;
	pcSectionGSA	= MODE_GP DATA_GSA;
	pcSectionGSV	= MODE_GP DATA_GSV;

	//解析RMC数据
	pcSection	= strstr(pcHead, pcSectionRMC);
	if (pcSection == NULL)
		return;
	ParseRMC(pcSection);

	PostMessage(HWND_BROADCAST, m_nMsgIDPosRefresh, 0, 0);

	//解析GGA数据
	pcSection	= strstr(pcHead, pcSectionGGA);
	if (pcSection == NULL)
		return;
	ParseGGA(pcSection);

	//解析GSA数据
	pcSection	= strstr(pcHead, pcSectionGSA);
	if (pcSection == NULL)
		return;
	ParseGSA(pcSection);

	//解析GSV数据
	pcSection	= strstr(pcHead, pcSectionGSV);
	if (pcSection == NULL)
		return;
	ParseGSV(pcSection, pcSectionGSV);

	//转发GPS数据
	SendGPS(pcPosData, dwLen);
}
Exemplo n.º 2
0
void gps_run(void *par)
{
  gps_byte_t tempBuff[16];
  gps_byte_t ch;
  int idx;

  gps_ser = fdserial_open(_gps_rx_pin, _gps_tx_pin, 0, _gps_baud);
  for(;;)
  {
    if(gps_stopping)
    {

      fdserial_close(gps_ser);
      gps_stopping = 0;
    }
    ch = fdserial_rxChar(gps_ser);
    
    //search for the start of an NMEA sentence
    if(ch != '$')
      continue;


    //read in characters from the GPS
    idx = 0;
    do
    {
      ch = fdserial_rxChar(gps_ser);
      inBuff[idx++] = ch;      
    }while(ch != 13);
    inBuff[idx] = 0;      //null terminate

    //got the full sentence, do a little prep work to get ready for parsing.
    //modifies inBuff!
    PrepBuff();

    if(strncmp(inBuff, "GPRMC", 5) == 0)
      ParseRMC();
    if(strncmp(inBuff, "GPGGA", 5) == 0)
      ParseGGA();
  }
}