Skip to content

Commit b3721ec

Browse files
authored
Merge pull request #36 from LeeLeahy2/get-sentence-name
Add semp*GetSentenceName to return the sentence name string
2 parents f47971c + 2ac3d37 commit b3721ec

File tree

7 files changed

+20
-8
lines changed

7 files changed

+20
-8
lines changed

Examples/Mixed_Parser/Mixed_Parser.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ void loop()
207207
// Process a complete message incoming from parser
208208
void processMessage(SEMP_PARSE_STATE *parse, uint16_t type)
209209
{
210-
SEMP_SCRATCH_PAD *scratchPad = (SEMP_SCRATCH_PAD *)parse->scratchPad;
211210
static bool displayOnce = true;
212211
uint32_t byteIndex;
213212
uint32_t offset;
@@ -226,7 +225,7 @@ void processMessage(SEMP_PARSE_STATE *parse, uint16_t type)
226225
byteIndex -= 1;
227226
}
228227
Serial.printf("Valid NMEA Sentence: %s, %d bytes at 0x%08x (%d)\r\n",
229-
scratchPad->nmea.sentenceName, parse->length, offset, offset);
228+
sempNmeaGetSentenceName(parse), parse->length, offset, offset);
230229
break;
231230

232231
case UBLOX_PARSER_INDEX:

Examples/Multiple_Parsers/Multiple_Parsers.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ void loop()
223223
// Process a complete message incoming from parser
224224
void nmeaSentence(SEMP_PARSE_STATE *parse, uint16_t type)
225225
{
226-
SEMP_SCRATCH_PAD *scratchPad = (SEMP_SCRATCH_PAD *)parse->scratchPad;
227226
uint32_t byteIndex;
228227
static bool displayOnce = true;
229228
uint32_t offset;
@@ -240,7 +239,7 @@ void nmeaSentence(SEMP_PARSE_STATE *parse, uint16_t type)
240239
// Display the raw sentence
241240
Serial.println();
242241
Serial.printf("Valid NMEA Sentence: %s, %d bytes at 0x%08x (%d)\r\n",
243-
scratchPad->nmea.sentenceName, parse->length, offset, offset);
242+
sempNmeaGetSentenceName(parse), parse->length, offset, offset);
244243
dumpBuffer(parse->buffer, parse->length);
245244

246245
// Display the parser state

Examples/NMEA_Test/NMEA_Test.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ void loop()
122122
// Process a complete message incoming from parser
123123
void processMessage(SEMP_PARSE_STATE *parse, uint16_t type)
124124
{
125-
SEMP_SCRATCH_PAD *scratchPad = (SEMP_SCRATCH_PAD *)parse->scratchPad;
126125
static bool displayOnce = true;
127126
uint32_t offset;
128127

@@ -134,7 +133,7 @@ void processMessage(SEMP_PARSE_STATE *parse, uint16_t type)
134133
// Display the raw message
135134
Serial.println();
136135
Serial.printf("Valid NMEA Sentence: %s, %d bytes at 0x%08x (%d)\r\n",
137-
scratchPad->nmea.sentenceName, parse->length, offset, offset);
136+
sempNmeaGetSentenceName(parse), parse->length, offset, offset);
138137
dumpBuffer(parse->buffer, parse->length);
139138

140139
// Display the parser state

Examples/Unicore_Hash_Test/Unicore_Hash_Test.ino

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ bool badUnicoreHashChecksum(SEMP_PARSE_STATE *parse)
153153
// Process a complete message incoming from parser
154154
void processMessage(SEMP_PARSE_STATE *parse, uint16_t type)
155155
{
156-
SEMP_SCRATCH_PAD *scratchPad = (SEMP_SCRATCH_PAD *)parse->scratchPad;
157156
uint32_t offset;
158157

159158
// Determine the raw data stream offset
@@ -164,7 +163,7 @@ void processMessage(SEMP_PARSE_STATE *parse, uint16_t type)
164163
// Display the raw message
165164
Serial.println();
166165
Serial.printf("Valid Unicore Hash (#) Sentence: %s, %d bytes at 0x%08x (%d)\r\n",
167-
scratchPad->unicoreHash.sentenceName, parse->length, offset, offset);
166+
sempUnicoreHashGetSentenceName(parse), parse->length, offset, offset);
168167
dumpBuffer(parse->buffer, parse->length);
169168
}
170169

src/Parse_NMEA.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,10 @@ const char * sempNmeaGetStateName(const SEMP_PARSE_STATE *parse)
287287
return "sempNmeaLineFeed";
288288
return nullptr;
289289
}
290+
291+
// Return the NMEA sentence name as a string
292+
const char * sempNmeaGetSentenceName(const SEMP_PARSE_STATE *parse)
293+
{
294+
SEMP_SCRATCH_PAD *scratchPad = (SEMP_SCRATCH_PAD *)parse->scratchPad;
295+
return (const char *)scratchPad->nmea.sentenceName;
296+
}

src/Parse_Unicore_Hash.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,3 +358,10 @@ const char * sempUnicoreHashGetStateName(const SEMP_PARSE_STATE *parse)
358358
return "sempUnicoreHashLineFeed";
359359
return nullptr;
360360
}
361+
362+
// Return the Unicore hash (#) sentence name as a string
363+
const char * sempUnicoreHashGetSentenceName(const SEMP_PARSE_STATE *parse)
364+
{
365+
SEMP_SCRATCH_PAD *scratchPad = (SEMP_SCRATCH_PAD *)parse->scratchPad;
366+
return (const char *)scratchPad->unicoreHash.sentenceName;
367+
}

src/SparkFun_Extensible_Message_Parser.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ void sempDisableErrorOutput(SEMP_PARSE_STATE *parse);
272272
bool sempNmeaPreamble(SEMP_PARSE_STATE *parse, uint8_t data);
273273
bool sempNmeaFindFirstComma(SEMP_PARSE_STATE *parse, uint8_t data);
274274
const char * sempNmeaGetStateName(const SEMP_PARSE_STATE *parse);
275+
const char * sempNmeaGetSentenceName(const SEMP_PARSE_STATE *parse);
275276

276277
// RTCM parse routines
277278
bool sempRtcmPreamble(SEMP_PARSE_STATE *parse, uint8_t data);
@@ -290,5 +291,6 @@ void sempUnicoreBinaryPrintHeader(SEMP_PARSE_STATE *parse);
290291
bool sempUnicoreHashPreamble(SEMP_PARSE_STATE *parse, uint8_t data);
291292
const char * sempUnicoreHashGetStateName(const SEMP_PARSE_STATE *parse);
292293
void sempUnicoreHashPrintHeader(SEMP_PARSE_STATE *parse);
294+
const char * sempUnicoreHashGetSentenceName(const SEMP_PARSE_STATE *parse);
293295

294296
#endif // __SPARKFUN_EXTENSIBLE_MESSAGE_PARSER_H__

0 commit comments

Comments
 (0)