11/* ------------------------------------------------------------------------------
22Parse_NMEA.cpp
33
4- NMEA message parsing support routines
4+ NMEA sentence parsing support routines
55
66The parser routines within a parser module are typically placed in
77reverse order within the module. This lets the routine declaration
@@ -28,7 +28,7 @@ License: MIT. Please see LICENSE.md for more details
2828// ----------------------------------------
2929
3030//
31- // NMEA Message
31+ // NMEA Sentence
3232//
3333// +----------+---------+--------+---------+----------+----------+
3434// | Preamble | Name | Comma | Data | Asterisk | Checksum |
@@ -74,7 +74,7 @@ bool sempNmeaChecksumByte2(SEMP_PARSE_STATE *parse, uint8_t data)
7474 return sempFirstByte (parse, data);
7575 }
7676
77- // Add CR and LF to the message
77+ // Add CR and LF to the sentence
7878 parse->buffer [parse->length ++] = ' \r ' ;
7979 parse->buffer [parse->length ++] = ' \n ' ;
8080
@@ -85,7 +85,7 @@ bool sempNmeaChecksumByte2(SEMP_PARSE_STATE *parse, uint8_t data)
8585 if ((checksum == parse->crc )
8686 || (parse->badCrc && (!parse->badCrc (parse))))
8787 {
88- // Process this NMEA message
88+ // Process this NMEA sentence
8989 parse->eomCallback (parse, parse->type ); // Pass parser array index
9090
9191 // Remove any CR or LF that follow
@@ -99,7 +99,7 @@ bool sempNmeaChecksumByte2(SEMP_PARSE_STATE *parse, uint8_t data)
9999 " SEMP: %s NMEA %s, %2d bytes, bad checksum, "
100100 " received 0x%c%c, computed: 0x%02x" ,
101101 parse->parserName ,
102- scratchPad->nmea .messageName ,
102+ scratchPad->nmea .sentenceName ,
103103 parse->length ,
104104 parse->buffer [parse->length - 4 ],
105105 parse->buffer [parse->length - 3 ],
@@ -129,7 +129,7 @@ bool sempNmeaChecksumByte1(SEMP_PARSE_STATE *parse, uint8_t data)
129129 return sempFirstByte (parse, data);
130130}
131131
132- // Read the message data
132+ // Read the sentence data
133133bool sempNmeaFindAsterisk (SEMP_PARSE_STATE *parse, uint8_t data)
134134{
135135 if (data == ' *' )
@@ -142,9 +142,9 @@ bool sempNmeaFindAsterisk(SEMP_PARSE_STATE *parse, uint8_t data)
142142 // Verify that enough space exists in the buffer
143143 if ((parse->length + NMEA_BUFFER_OVERHEAD) > parse->bufferLength )
144144 {
145- // Message too long
145+ // sentence too long
146146 sempPrintf (parse->printDebug ,
147- " SEMP %s: NMEA message too long, increase the buffer size > %d" ,
147+ " SEMP %s: NMEA sentence too long, increase the buffer size > %d" ,
148148 parse->parserName ,
149149 parse->bufferLength );
150150
@@ -155,40 +155,40 @@ bool sempNmeaFindAsterisk(SEMP_PARSE_STATE *parse, uint8_t data)
155155 return true ;
156156}
157157
158- // Read the message name
158+ // Read the sentence name
159159bool sempNmeaFindFirstComma (SEMP_PARSE_STATE *parse, uint8_t data)
160160{
161161 SEMP_SCRATCH_PAD *scratchPad = (SEMP_SCRATCH_PAD *)parse->scratchPad ;
162162 parse->crc ^= data;
163- if ((data != ' ,' ) || (scratchPad->nmea .messageNameLength == 0 ))
163+ if ((data != ' ,' ) || (scratchPad->nmea .sentenceNameLength == 0 ))
164164 {
165165 // Invalid data, start searching for a preamble byte
166166 uint8_t upper = data & ~0x20 ;
167167 if (((upper < ' A' ) || (upper > ' Z' )) && ((data < ' 0' ) || (data > ' 9' )))
168168 {
169169 sempPrintf (parse->printDebug ,
170- " SEMP %s: NMEA invalid message name character 0x%02x" ,
170+ " SEMP %s: NMEA invalid sentence name character 0x%02x" ,
171171 parse->parserName , data);
172172 return sempFirstByte (parse, data);
173173 }
174174
175175 // Name too long, start searching for a preamble byte
176- if (scratchPad->nmea .messageNameLength == (sizeof (scratchPad->nmea .messageName ) - 1 ))
176+ if (scratchPad->nmea .sentenceNameLength == (sizeof (scratchPad->nmea .sentenceName ) - 1 ))
177177 {
178178 sempPrintf (parse->printDebug ,
179- " SEMP %s: NMEA message name > %d characters" ,
179+ " SEMP %s: NMEA sentence name > %d characters" ,
180180 parse->parserName ,
181- sizeof (scratchPad->nmea .messageName ) - 1 );
181+ sizeof (scratchPad->nmea .sentenceName ) - 1 );
182182 return sempFirstByte (parse, data);
183183 }
184184
185- // Save the message name
186- scratchPad->nmea .messageName [scratchPad->nmea .messageNameLength ++] = data;
185+ // Save the sentence name
186+ scratchPad->nmea .sentenceName [scratchPad->nmea .sentenceNameLength ++] = data;
187187 }
188188 else
189189 {
190- // Zero terminate the message name
191- scratchPad->nmea .messageName [scratchPad->nmea .messageNameLength ++] = 0 ;
190+ // Zero terminate the sentence name
191+ scratchPad->nmea .sentenceName [scratchPad->nmea .sentenceNameLength ++] = 0 ;
192192 parse->state = sempNmeaFindAsterisk;
193193 }
194194 return true ;
@@ -200,7 +200,7 @@ bool sempNmeaPreamble(SEMP_PARSE_STATE *parse, uint8_t data)
200200 SEMP_SCRATCH_PAD *scratchPad = (SEMP_SCRATCH_PAD *)parse->scratchPad ;
201201 if (data != ' $' )
202202 return false ;
203- scratchPad->nmea .messageNameLength = 0 ;
203+ scratchPad->nmea .sentenceNameLength = 0 ;
204204 parse->state = sempNmeaFindFirstComma;
205205 return true ;
206206}
@@ -211,7 +211,7 @@ bool sempNmeaHashPreamble(SEMP_PARSE_STATE *parse, uint8_t data)
211211 SEMP_SCRATCH_PAD *scratchPad = (SEMP_SCRATCH_PAD *)parse->scratchPad ;
212212 if (data != ' #' )
213213 return false ;
214- scratchPad->nmea .messageNameLength = 0 ;
214+ scratchPad->nmea .sentenceNameLength = 0 ;
215215 parse->state = sempNmeaFindFirstComma;
216216 return true ;
217217}
0 commit comments