VC ++ implements extraction of GPS Global Positioning System Positioning Data

xiaoxiao2021-03-05  26

Abstract: This paper proposes a method of receiving the GPS Global Positioning System Positioning Information under VC and an extraction method for each positioning parameter data. Introduction The rapid development of satellite navigation technology has gradually replaced traditional navigation technology such as radio navigation, astronomical navigation, and has become a general navigation positioning technology, and has made great progress in precision, real-time, all-weather, etc. Not only is applied to many civil engineering, including physical exploration, ionization layer measurement and spacecraft navigation, but also has achieved extensive applications in the military field - all in the fields of ballistic missiles, field command systems, accurate ballistic measurements, and military maps. A large number of satellite navigation positioning techniques were used. In view of the importance of satellite navigation technology in civilian and military fields, it has got the attention of many countries. my country has also successfully launched the first and second navigation positioning test satellites and established my country's first generation satellite navigation positioning system in China on October 31 and 21, 2000 - "Beidou Navigation System", but due to starting Nothing is not widely used. The most used in my country is still the US GPS system. This article introduces the implementation method of the reception of its satellite positioning information and its positioning parameters extracted by the current relatively popular GPS system. The reception of positioning information is typically composed of a GPS positioning information receiving system consists of a GPS receiving antenna, a frequency converter, a signal channel, a microprocessor, a memory, and a power source. Since the GPS positioning information is less, multi-RS-232 serial port transmits positioning information (NEMA0183 statement) from the GPS receiver to the computer for information extraction processing. There are several ways to read data from the serial port, where it is programmed directly with the Win32 API function. The hardware port is not allowed to control the hardware port under Windows, all ports are treated as "file", so it is necessary to open the serial port before listening to the serial port, and perform related parameter configurations on the user before listening to the serial port.

M_HCOM = CREATEFILE ("COM1", Generic_Read | Generic_Write, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); File: // Open COM1 PortCommmask (M_HCOM, EV_RXCHAR) in asynchronous mode; file: // Add or modify Windows report report Event list setupcomm (m_hcom, readbufflen / * read buffer * /, WriteBuflen / * write buffer * /); // Initialization communication device parameter // Clear buffer information PurgeComm (m_hcom, purge_txabort | purge_rxabort | purge_txclear | purge_rxclear); // asynchronous I / O is provided CommTimeOuts.ReadIntervalTimeout = MAXDWORD; file: // receiving two consecutive bytes maximum time interval CommTimeOuts.ReadTotalTimeoutMultiplier = 0; file: // for each byte received average allowable time CommTimeOuts.ReadTotalTimeoutConstant = 0; FILE: / / Receive time constant setcommtimeouts (m_hcom, & commtimeouts); file: // Get and set the serial portcommstate (M_HCOM, & DCB); dcb.baudrate = CBR_4800; dcb.bytesize = 8; dcb.parity = oddparity; dcb.stopbits = Onestopbit; setcommstate (M_HCOM, & DCB);

After successful opening and seting the communication port, the polling serial port and event trigger can be taken to receive the data, and this article takes a reception process in the event trigger mode in which the efficiency is relatively high, by waiting for the occurrence of the EV_RXCHAR event to start readfile. The function completes the reception 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);} extract positioning data from the GPS receiver As long as the operation is in the working state, it will continue to transmit the received and calculated GPS navigation positioning information through the serial port to the computer. The previous code is only responsible for receiving data from the serial port and placing it in a cache, which is a long string byte stream in the caching before further processing, which cannot be utilized before the classification extraction. Therefore, it is necessary to extract the information of each field from the cache paragraph stream via the program, and the positioning information data that is converted to the actual significance can be used. Similar to other communication protocols, the information extraction of GPS must first clarify its frame structure, and then the extraction of each positioning information is completed according to its structure. For the Garmin GPS antenna board used herein, the data sent to the computer is mainly composed of frame head, frame end, and intra data, depending on the data frame, the frame head is not the same, mainly "$ GPGGA", "$ GPGSA, "$ GPGSV", and "$ GPRMC", etc.. These frame headers identify the compositional structure of subsequent intra data, each frame, and the end of the frame, the end of the frame, and the end of the frame. For usual cases, our positioning data, such as latitude and longitude, speed, time, etc., can be obtained from the "$ GPRMC" frame, the structure of the frame and the respective fields, as follows: $ GPRMC, <1>, <2> , <3>, <4>, <5>, <9>, <10>, <11> * hh <1> GMT in the current location, format is HHMMSS <2> State, A is a valid location, V is a non-effective receive warning, namely the number of satellites above the current antenna point of less than 3. <3> latitude, format is ddmm.mmmm <4> indicated North-South hemisphere, N is the northern hemisphere, S is the southern hemisphere <5>, the format is DDDMM.Mmmm <6> indicated east and hemisphere, E is the East Hemisphere, W is the western hemisphere < 7> The speed of the ground is 0.0 to 999.9 <8> azimuth, range from 000.0 to 359.9 degrees <9> Date, format is DDMMYY <10> Diomagnetic changes, from 000.0 to 180.0 degrees <11> Genomagnetic change direction, For E or W is not commonly used in other frame formats, in addition to special purposes, it is not commonly used. Although the receiver also sends a variety of data frames to the host, it generally passes the judgment of the frame. Only the data extraction processing is performed on the "$ GPRMC" frame. If the situation is special, you need to get data from other frames, and the processing method is also totally similar. Since each data segment is divided by a comma, it is generally determined whether it is a frame header when the cache data is processed, and the number of the category is performed after the category of the frame. The count is to determine which positioning navigation parameter is currently being processed and processed accordingly. Below is the primary code for unfractioning the data in the cache data, this article only cares about the time (date and time) and geographic coordinates (through latitude):

For (int i = 0; i

:: strcpy (buf, m_stime); str.format ("% C% C", BUF [0], BUF [1]); GPSPARAM [M_NNUMBER] .M_NHOUR = (ATOI (STR) 8)% 24; File : // Extract the hour and convert to 24-hour system Beijing time file: // BUF 2nd, 3 bytes for minute, 4, 5 bytes are second, extraction method is the same ... :: strcpy (buf, m_sdate); Str.Format ("% C% C", BUF [0], BUF [1]); file: // Extract the month File: // BUF 2nd, 3 bytes, 4, 5 bytes as the year Extraction method is the same as above ... :: strcpy (buf, m_spositiony); str.format ("% C% C", BUF [0], BUF [1]); PositionValue = ATOI (STR); str.format ("% C% C% C% C% C% C% C ", BUF [2], BUF [3], BUF [4], BUF [5], BUF [6], BUF [7], BUF [8]) GPsparam [m_nnumber] .m_dpositiony = PositionValue * 60 ATOF (STR); file: // Extract the latitude ... :: strcpy (buf, m_spositionx); if (m_spositionx.getlength () == 10) File: // With more than 90 degrees (such as 125 degrees East) {Str.Format ("% C% C% C", BUF [0], BUF [1], BUF [2]); PositionValue = ATOI (STR); str.Format ("% C% C% C% C% C% C% C", BUF [3], BUF [4], BUF [5], BUF [6], BUF [7], BUF [8], BUF [ 9]); gpsparam [m_nnumber] .m_dpositionX = positionValue * 60 atof (str); file: // Extracts the longitude (in points)} if (m_spositionx.getlength () == 9) File: // long More than 90 degrees (e.g., an East Economic 89 degree) {file: // Treatment method, only the 0th, 1 byte of BUF is the number of degrees, 2 to 9 is score. This is to this, and the time and latitude and longitude information have been extracted into each variable in the GPS structure array GPSPARAM, subsequent processing and high-level decisions can be processed according to the data stored in this structure. Small junctions Combined with the main related procedures to discuss the extraction of the reception and parameter data of the positioning navigation information of the GPS global positioning system, but also briefly describe the programming of the serial port. Through the design method of this article, GPS positioning navigation information can be fully received from the GPS receiver. By extracting the positioning parameters can be applied to other high-level application decisions such as various GIS, RS systems, etc. This article is compiled by Microsoft Visual C 6.0 under Windows 98.

转载请注明原文地址:https://www.9cbs.com/read-32740.html

New Post(0)