The realization of GPS positioning data extraction by VC + +

Source: Internet
Author: User
Tags readfile

Introduction

The rapid development of satellite navigation technology has gradually replaced the traditional navigation technology, such as radio navigation and astronomical navigation, and become a widely used navigation and positioning technology, and has made great progress in precision, real-time, all-weather and so on. It is not only applied in many civil fields such as physical exploration, ionospheric measurement and spacecraft navigation, but also has been widely used in military field----------------------------------------- In view of the importance of satellite navigation technology in both the civilian and military spheres, it has received the attention of many countries. Our country also successfully launched the first and second navigation and positioning test satellite on October 31, 2000 and December 21, and established our country's first generation of satellite navigation and positioning System-"Beidou navigation system", but it was not widely used since late start. At present, the most used in China is the United States GPS system. In this paper, according to the current GPS system, the realization method of the satellite location information receiving and locating parameter extraction is introduced.

Receiving of location information

Usually the GPS positioning information receiving system is mainly composed of GPs receiving antenna, frequency converter, signal channel, microprocessor, memory and power supply. Because of the low content of GPS positioning information, the RS-232 serial port is used to transfer the positioning information (NEMA0183 statement) from GPS receiver to computer for information extraction and processing. There are several ways to read data from a serial port, which is programmed directly using the Win32 API function. It is not allowed to control the hardware ports directly under Windows, all ports are considered "files", so you need to open the serial port by opening the file before you listen to the serial port and configure it with the relevant parameters:

m_hCom=CreateFile("COM1",GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING, FILE_FLAG_OVERLAPPED,NULL); file://以异步方式打开COM1口
SetCommMask (m_hCom, EV_RXCHAR ) ; file://添加或修改Windows所报告的事件列表
SetupComm (m_hCom,READBUFLEN/*读缓冲*/,WRITEBUFLEN/*写缓冲*/); // 初始化通讯设备参数
// 清除缓冲信息
PurgeComm (m_hCom, PURGE_TXABORT | PURGE_RXABORT | PURGE_TXCLEAR | PURGE_RXCLEAR) ;
// 对异步I/O进行设置
CommTimeOuts.ReadIntervalTimeout = MAXDWORD ; file://接收两连续字节的最大时间间隔
CommTimeOuts.ReadTotalTimeoutMultiplier =0; file://接收每字节的平均允许时间
CommTimeOuts.ReadTotalTimeoutConstant = 0 ; file://接收时间常数
SetCommTimeouts (m_hCom , &CommTimeOuts) ;
file://获取并设置串口
GetCommState ( m_hCom, &dcb) ;
dcb.BaudRate = CBR_4800;
dcb.ByteSize = 8;
dcb.Parity = ODDPARITY;
dcb.StopBits = ONESTOPBIT ;
SetCommState( m_hCom, &dcb);

After successfully opening and setting up the communication port, we can adopt the polling serial port and event trigger to receive and deal with the data, in this paper, we take the event triggering method with higher efficiency to receive processing, and start the ReadFile function by waiting for the occurrence of Ev_rxchar event to complete the receiving of GPS positioning information:

while(true){
 WaitCommEvent (m_hCom,&dwEvtMask,NULL);
 if (dwEvtMask&EV_RXCHAR == EV_RXCHAR)
  if(ComStat.cbInQue>0)
   ReadFile(m_hCom,m_readbuf,ComStat.cbInQue,&nLength,&olRead);
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.