Skip to content

Commit 54a3448

Browse files
committed
User_Parser: Add userParserGetMessageNumber to return the message number
1 parent 2ac3d37 commit 54a3448

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Examples/User_Parser/User_Parser.ino

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ const char * userParserStateName(const SEMP_PARSE_STATE *parse)
8888
return nullptr;
8989
}
9090

91+
// Return the message number value
92+
uint32_t userParserGetMessageNumber(const SEMP_PARSE_STATE *parse)
93+
{
94+
USER_SCRATCH_PAD *scratchPad = (USER_SCRATCH_PAD *)parse->scratchPad;
95+
return scratchPad->messageNumber;
96+
}
97+
9198
//----------------------------------------
9299
// Constants
93100
//----------------------------------------
@@ -204,15 +211,14 @@ void loop()
204211
// Process a complete message incoming from parser
205212
void userMessage(SEMP_PARSE_STATE *parse, uint16_t type)
206213
{
207-
USER_SCRATCH_PAD *scratchPad = (USER_SCRATCH_PAD *)parse->scratchPad;
208214
static bool displayOnce = true;
209215
uint32_t offset;
210216

211217
// Display the raw message
212218
Serial.println();
213219
offset = dataOffset + 1 - parse->length;
214220
Serial.printf("Valid Message %d, %d bytes at 0x%08x (%d)\r\n",
215-
scratchPad->messageNumber, parse->length, offset, offset);
221+
userParserGetMessageNumber(parse), parse->length, offset, offset);
216222
dumpBuffer(parse->buffer, parse->length);
217223

218224
// Display the parser state

0 commit comments

Comments
 (0)