Skip to content

Commit 59e92a7

Browse files
authored
Merge pull request #30 from LeeLeahy2/sentence
NMEA uses sentences instead of messages
2 parents f7a967c + b4bb8c3 commit 59e92a7

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

Examples/Mixed_Parser/Mixed_Parser.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const char * const parserNames[] =
2525
};
2626
const int parserNameCount = sizeof(parserNames) / sizeof(parserNames[0]);
2727

28-
// Provide a mix of NMEa and u-blox messages
28+
// Provide a mix of NMEA sentences and u-blox messages
2929
const uint8_t nmea_1[] =
3030
{
3131
"$GPRMC,210230,A,3855.4487,N,09446.0071,W,0.0,076.2,130495,003.8,E*69" //0
@@ -212,8 +212,8 @@ void processMessage(SEMP_PARSE_STATE *parse, uint16_t type)
212212
{
213213
case 0:
214214
offset = dataOffset + 1 + 2 - parse->length;
215-
Serial.printf("Valid NMEA Message: %s, %d bytes at 0x%08x (%d)\r\n",
216-
scratchPad->nmea.messageName, parse->length, offset, offset);
215+
Serial.printf("Valid NMEA Sentence: %s, %d bytes at 0x%08x (%d)\r\n",
216+
scratchPad->nmea.sentenceName, parse->length, offset, offset);
217217
break;
218218

219219
case 1:

Examples/Multiple_Parsers/Multiple_Parsers.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// Constants
1111
//----------------------------------------
1212

13-
// Provide a mix of NMEa and u-blox messages
13+
// Provide a mix of NMEA sentences and u-blox messages
1414
const uint8_t nmea_1[] =
1515
{
1616
"$GPRMC,210230,A,3855.4487,N,09446.0071,W,0.0,076.2,130495,003.8,E*69" //0
@@ -177,7 +177,7 @@ void setup()
177177
// Initialize the parsers
178178
nmeaParser = sempBeginParser(nmeaParserTable, nmeaParserCount,
179179
nmeaParserNames, nmeaParserNameCount,
180-
0, BUFFER_LENGTH, nmeaMessage, "NMEA_Parser");
180+
0, BUFFER_LENGTH, nmeaSentence, "NMEA_Parser");
181181
if (!nmeaParser)
182182
reportFatalError("Failed to initialize the NMEA parser");
183183
ubloxParser = sempBeginParser(ubloxParserTable, ubloxParserCount,
@@ -220,17 +220,17 @@ void loop()
220220

221221
// Call back from within parser, for end of message
222222
// Process a complete message incoming from parser
223-
void nmeaMessage(SEMP_PARSE_STATE *parse, uint16_t type)
223+
void nmeaSentence(SEMP_PARSE_STATE *parse, uint16_t type)
224224
{
225225
SEMP_SCRATCH_PAD *scratchPad = (SEMP_SCRATCH_PAD *)parse->scratchPad;
226226
static bool displayOnce = true;
227227
uint32_t offset;
228228

229-
// Display the raw message
229+
// Display the raw sentence
230230
Serial.println();
231231
offset = dataOffset + 1 + 2 - parse->length;
232-
Serial.printf("Valid NMEA Message: %s, %d bytes at 0x%08x (%d)\r\n",
233-
scratchPad->nmea.messageName, parse->length, offset, offset);
232+
Serial.printf("Valid NMEA Sentence: %s, %d bytes at 0x%08x (%d)\r\n",
233+
scratchPad->nmea.sentenceName, parse->length, offset, offset);
234234
dumpBuffer(parse->buffer, parse->length);
235235

236236
// Display the parser state

Examples/NMEA_Test/NMEA_Test.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const uint8_t rawDataStream[] =
5151
//1234567890123456
5252
"$ABCDEFGHIJKLMNOP,210230,A,3855.4487,N,09446.0071,W,0.0,076.2,130*6A\r\n" // 561
5353

54-
// Invalid character in the message name
54+
// Invalid character in the sentence name
5555
"$G@RMC,210230,A,3855.4487,N,09446.0071,W,0.0,076.2,130495,003.8,E*69\r\n" // 631
5656
"$G[RMC,210230,A,3855.4487,N,09446.0071,W,0.0,076.2,130495,003.8,E*69\r\n" // 701
5757
"$GaRMC,210230,A,3855.4487,N,09446.0071,W,0.0,076.2,130495,003.8,E*69\r\n" // 771
@@ -129,8 +129,8 @@ void processMessage(SEMP_PARSE_STATE *parse, uint16_t type)
129129
// Display the raw message
130130
Serial.println();
131131
offset = dataOffset + 1 + 2 - parse->length;
132-
Serial.printf("Valid NMEA Message: %s, %d bytes at 0x%08x (%d)\r\n",
133-
scratchPad->nmea.messageName, parse->length, offset, offset);
132+
Serial.printf("Valid NMEA Sentence: %s, %d bytes at 0x%08x (%d)\r\n",
133+
scratchPad->nmea.sentenceName, parse->length, offset, offset);
134134
dumpBuffer(parse->buffer, parse->length);
135135

136136
// Display the parser state

src/Parse_NMEA.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*------------------------------------------------------------------------------
22
Parse_NMEA.cpp
33
4-
NMEA message parsing support routines
4+
NMEA sentence parsing support routines
55
66
The parser routines within a parser module are typically placed in
77
reverse 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
133133
bool 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
159159
bool 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
}

src/SparkFun_Extensible_Message_Parser.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ typedef bool (*SEMP_BAD_CRC_CALLBACK)(P_SEMP_PARSE_STATE parse); // Parser state
5151
typedef void (*SEMP_EOM_CALLBACK)(P_SEMP_PARSE_STATE parse, // Parser state
5252
uint16_t type); // Index into parseTable
5353

54-
// Length of the message name array
55-
#define SEMP_NMEA_MESSAGE_NAME_BYTES 16
54+
// Length of the sentence name array
55+
#define SEMP_NMEA_SENTENCE_NAME_BYTES 16
5656

5757
// NMEA parser scratch area
5858
typedef struct _SEMP_NMEA_VALUES
5959
{
60-
uint8_t messageName[SEMP_NMEA_MESSAGE_NAME_BYTES]; // Message name
61-
uint8_t messageNameLength; // Length of the message name
60+
uint8_t sentenceName[SEMP_NMEA_SENTENCE_NAME_BYTES]; // Sentence name
61+
uint8_t sentenceNameLength; // Length of the sentence name
6262
} SEMP_NMEA_VALUES;
6363

6464
// RTCM parser scratch area

0 commit comments

Comments
 (0)