The NMEA 0813 standard for interfacing marine electronics devices specifies the NMEA data sentence structure as well as general definitions of approved sentences. 해양 전자 장치 인터페이스를 위한 NMEA 0813 표준은 NMEA 데이터 문장 구조와 승인된 문장의 일반적인 정의를 지정합니다. However, the specification does not cover implementation and design. 그러나 사양은 구현 및 설계를 다루지 않습니다. This article will hopefully clarify some of the design tasks needed to parse through NMEA sentences robustly. 이 기사는 NMEA 문장을 강력하게 구문 분석하는 데 필요한 설계 작업 중 일부를 명확히 할 것입니다. It will try to show techniques in parsing and data integrity checking. 구문 분석 및 데이터 무결성 검사 기술을 보여주려고 합니다. The article does assume that the reader has knowledge in software design and has experience in some sort of programming language. 이 기사는 독자가 소프트웨어 설계에 대한 지식이 있고 일종의 프로그래밍 언어에 대한 경험이 있다고 가정합니다. This article will reference the NMEA 0183 specification and it is recommended that the NMEA 0813 specification be available as a reference. 이 문서에서는 NMEA 0183 사양을 참조하며 NMEA 0813 사양을 참조로 사용할 수 있도록 권장합니다. This article makes no assumption of the media that the NMEA data is acquired. The techniques here can be applied on received data from a higher abstraction layer. 이 기사는 NMEA 데이터가 획득되었다는 매체를 가정하지 않습니다. 여기서 기술은 상위 추상화 계층에서 수신된 데이터에 적용될 수 있습니다. A simple example written in C++ demonstrates this parser design. C++로 작성된 간단한 예제는 이 파서 디자인을 보여줍니다.
NMEA Protocol NMEA 프로토콜 NMEA data is sent in 8-bit ASCII where the MSB is set to zero (0). NMEA 데이터는 MSB가 0으로 설정된 8비트 ASCII로 전송됩니다. The specification also has a set of reserved characters. 사양에는 예약된 문자 집합도 있습니다. These characters assist in the formatting of the NMEA data string. 이러한 문자는 NMEA 데이터 문자열의 형식을 지정하는 데 도움이 됩니다. The specification also states valid characters and gives a table of these characters ranging from HEX 20 to HEX 7E. 사양은 또한 유효한 문자를 명시하고 HEX 20에서 HEX 7E 범위의 이러한 문자 테이블을 제공합니다. As stated in the NMEA 0183 specification version 3.01 the maximum number of characters shall be 82, consisting of a maximum of 79 characters between start of message “$” or “!” and terminating delimiter <CR><LF> (HEX 0D and 0A). NMEA 0183 사양 버전 3.01에 명시된 대로 최대 문자 수는 "$" 또는 "!" 메시지 시작 사이의 최대 79자로 구성된 82자입니다. 종료 구분 기호 <CR><LF>(HEX 0D 및 0A). The minimum number of fields is one (1). 최소 필드 수는 1입니다.
Basic sentence format: 기본 문장 형식: $aaccc,c--c*hh<CR><LF> $ Start of sentence aaccc Address field/Command “,” Field delimiter (Hex 2C) c--c Data sentence block
Most protocols have a state machine tracking the protocol state and any errors that may occur during the data transfer. The NMEA parser we are discussing is based on a simple state machine. By using a state machine the computer can easily keep track of where it is within the protocol as well as recover from any errors such as timeouts and checksum errors.
The parsing example is designed such that a buffer can be sent to the parser along with the buffer length to maximize the computer processor efficiency. This will allow the computer to parse data when it is received. Since NMEA data is typically sent at 4800 baud, computers are often waiting for data. By having a state machine in place, partial or complete sets of NMEA data may be parsed. If only a partial set of data was received and sent to the parser, then when the rest of the data is received, the parser will complete any NMEA sentence that may have been incomplete.
Below, Figure 1 illustrates the data flow to the NMEA parser. Our design will assume two abstract software layers, NMEA protocol parser and specific NMEA sentence parser. It does not matter the number of data bytes received or if there is only a partial message. The NMEA parser will manage the data and extract individual NMEA sentences.