Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Examples/Base_Test/Base_Test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void setup()
// Display the parser configuration
Serial.printf("&parserTable: %p\r\n", parserTable);
Serial.printf("&parserNames: %p\r\n", parserNames);
sempPrintParserConfiguration(parse);
sempPrintParserConfiguration(parse, &Serial);

// Display the parse state
Serial.printf("Parse State: %s\r\n", sempGetStateName(parse));
Expand Down Expand Up @@ -164,7 +164,7 @@ void processMessage(SEMP_PARSE_STATE *parse, uint16_t type)
{
displayOnce = false;
Serial.println();
sempPrintParserConfiguration(parse);
sempPrintParserConfiguration(parse, &Serial);
}
}

Expand Down
33 changes: 23 additions & 10 deletions Examples/Mixed_Parser/Mixed_Parser.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
// Constants
//----------------------------------------

// Define the indexes into the parserTable array
#define NMEA_PARSER_INDEX 0
#define UBLOX_PARSER_INDEX 1

// Build the table listing all of the parsers
SEMP_PARSE_ROUTINE const parserTable[] =
{
Expand All @@ -25,7 +29,7 @@ const char * const parserNames[] =
};
const int parserNameCount = sizeof(parserNames) / sizeof(parserNames[0]);

// Provide a mix of NMEa and u-blox messages
// Provide a mix of NMEA sentences and u-blox messages
const uint8_t nmea_1[] =
{
"$GPRMC,210230,A,3855.4487,N,09446.0071,W,0.0,076.2,130495,003.8,E*69" //0
Expand Down Expand Up @@ -144,6 +148,8 @@ const DataStream dataStream[] =
// Locals
//----------------------------------------

int byteOffset;
int dataIndex;
uint32_t dataOffset;
SEMP_PARSE_STATE *parse;

Expand All @@ -154,7 +160,6 @@ SEMP_PARSE_STATE *parse;
// Initialize the system
void setup()
{
int dataIndex;
int rawDataBytes;

delay(1000);
Expand All @@ -181,10 +186,10 @@ void setup()
sempEnableDebugOutput(parse);
for (dataIndex = 0; dataIndex < DATA_STREAM_ENTRIES; dataIndex++)
{
for (int offset = 0; offset < dataStream[dataIndex].length; offset++)
for (byteOffset = 0; byteOffset < dataStream[dataIndex].length; byteOffset++)
{
// Update the parser state based on the incoming byte
sempParseNextByte(parse, dataStream[dataIndex].data[offset]);
sempParseNextByte(parse, dataStream[dataIndex].data[byteOffset]);
dataOffset += 1;
}
}
Expand All @@ -204,19 +209,27 @@ void processMessage(SEMP_PARSE_STATE *parse, uint16_t type)
{
SEMP_SCRATCH_PAD *scratchPad = (SEMP_SCRATCH_PAD *)parse->scratchPad;
static bool displayOnce = true;
uint32_t byteIndex;
uint32_t offset;

// Display the raw message
Serial.println();
switch (type) // Index into parserTable array
{
case 0:
offset = dataOffset + 1 + 2 - parse->length;
Serial.printf("Valid NMEA Message: %s, %d bytes at 0x%08x (%d)\r\n",
scratchPad->nmea.messageName, parse->length, offset, offset);
case NMEA_PARSER_INDEX:
// Determine the raw data stream offset
offset = dataOffset + 2 - parse->length;
byteIndex = byteOffset + 2 - parse->length;
while (dataStream[dataIndex].data[byteIndex] != '$')
{
offset -= 1;
byteIndex -= 1;
}
Serial.printf("Valid NMEA Sentence: %s, %d bytes at 0x%08x (%d)\r\n",
scratchPad->nmea.sentenceName, parse->length, offset, offset);
break;

case 1:
case UBLOX_PARSER_INDEX:
offset = dataOffset + 1 - parse->length;
Serial.printf("Valid u-blox message: %d bytes at 0x%08x (%d)\r\n",
parse->length, offset, offset);
Expand All @@ -229,7 +242,7 @@ void processMessage(SEMP_PARSE_STATE *parse, uint16_t type)
{
displayOnce = false;
Serial.println();
sempPrintParserConfiguration(parse);
sempPrintParserConfiguration(parse, &Serial);
}
}

Expand Down
36 changes: 23 additions & 13 deletions Examples/Multiple_Parsers/Multiple_Parsers.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// Constants
//----------------------------------------

// Provide a mix of NMEa and u-blox messages
// Provide a mix of NMEA sentences and u-blox messages
const uint8_t nmea_1[] =
{
"$GPRMC,210230,A,3855.4487,N,09446.0071,W,0.0,076.2,130495,003.8,E*69" //0
Expand Down Expand Up @@ -153,6 +153,8 @@ const int ubloxParserNameCount = sizeof(ubloxParserNames) / sizeof(ubloxParserNa
// Locals
//----------------------------------------

int byteOffset;
int dataIndex;
uint32_t dataOffset;
SEMP_PARSE_STATE *nmeaParser;
SEMP_PARSE_STATE *ubloxParser;
Expand All @@ -164,7 +166,6 @@ SEMP_PARSE_STATE *ubloxParser;
// Initialize the system
void setup()
{
int dataIndex;
int rawDataBytes;

delay(1000);
Expand All @@ -177,7 +178,7 @@ void setup()
// Initialize the parsers
nmeaParser = sempBeginParser(nmeaParserTable, nmeaParserCount,
nmeaParserNames, nmeaParserNameCount,
0, BUFFER_LENGTH, nmeaMessage, "NMEA_Parser");
0, BUFFER_LENGTH, nmeaSentence, "NMEA_Parser");
if (!nmeaParser)
reportFatalError("Failed to initialize the NMEA parser");
ubloxParser = sempBeginParser(ubloxParserTable, ubloxParserCount,
Expand All @@ -197,11 +198,11 @@ void setup()
sempEnableDebugOutput(ubloxParser);
for (dataIndex = 0; dataIndex < DATA_STREAM_ENTRIES; dataIndex++)
{
for (int offset = 0; offset < dataStream[dataIndex].length; offset++)
for (byteOffset = 0; byteOffset < dataStream[dataIndex].length; byteOffset++)
{
// Update the parser state based on the incoming byte
sempParseNextByte(nmeaParser, dataStream[dataIndex].data[offset]);
sempParseNextByte(ubloxParser, dataStream[dataIndex].data[offset]);
sempParseNextByte(nmeaParser, dataStream[dataIndex].data[byteOffset]);
sempParseNextByte(ubloxParser, dataStream[dataIndex].data[byteOffset]);
dataOffset += 1;
}
}
Expand All @@ -220,25 +221,34 @@ void loop()

// Call back from within parser, for end of message
// Process a complete message incoming from parser
void nmeaMessage(SEMP_PARSE_STATE *parse, uint16_t type)
void nmeaSentence(SEMP_PARSE_STATE *parse, uint16_t type)
{
SEMP_SCRATCH_PAD *scratchPad = (SEMP_SCRATCH_PAD *)parse->scratchPad;
uint32_t byteIndex;
static bool displayOnce = true;
uint32_t offset;

// Display the raw message
// Determine the raw data stream offset
offset = dataOffset + 2 - parse->length;
byteIndex = byteOffset + 2 - parse->length;
while (dataStream[dataIndex].data[byteIndex] != '$')
{
offset -= 1;
byteIndex -= 1;
}

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

// Display the parser state
if (displayOnce)
{
displayOnce = false;
Serial.println();
sempPrintParserConfiguration(parse);
sempPrintParserConfiguration(parse, &Serial);
}
}

Expand All @@ -261,7 +271,7 @@ void ubloxMessage(SEMP_PARSE_STATE *parse, uint16_t type)
{
displayOnce = false;
Serial.println();
sempPrintParserConfiguration(parse);
sempPrintParserConfiguration(parse, &Serial);
}
}

Expand Down
18 changes: 11 additions & 7 deletions Examples/NMEA_Test/NMEA_Test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ const uint8_t rawDataStream[] =
//1234567890123456
"$ABCDEFGHIJKLMNOP,210230,A,3855.4487,N,09446.0071,W,0.0,076.2,130*6A\r\n" // 561

// Invalid character in the message name
// Invalid character in the sentence name
"$G@RMC,210230,A,3855.4487,N,09446.0071,W,0.0,076.2,130495,003.8,E*69\r\n" // 631
"$G[RMC,210230,A,3855.4487,N,09446.0071,W,0.0,076.2,130495,003.8,E*69\r\n" // 701
"$GaRMC,210230,A,3855.4487,N,09446.0071,W,0.0,076.2,130495,003.8,E*69\r\n" // 771
"$GzRMC,210230,A,3855.4487,N,09446.0071,W,0.0,076.2,130495,003.8,E*69\r\n" // 841

// Bad checksum
"$GaRMC,210230,A,3855.4487,N,09446.0071,W,0.0,076.2,130495,003.8,E*69\r\n" // 771
"$GzRMC,210230,A,3855.4487,N,09446.0071,W,0.0,076.2,130495,003.8,E*69\r\n" // 841
"$GPRMC,210230,A,3855.4487,N,09446.0071,W,0.0,076.2,130495,003.8,E*68\r\n" // 911

// Sentence too long by a single byte
Expand Down Expand Up @@ -126,19 +126,23 @@ void processMessage(SEMP_PARSE_STATE *parse, uint16_t type)
static bool displayOnce = true;
uint32_t offset;

// Determine the raw data stream offset
offset = dataOffset + 1 + 2 - parse->length;
while (rawDataStream[offset] != '$')
offset -= 1;

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

// Display the parser state
if (displayOnce)
{
displayOnce = false;
Serial.println();
sempPrintParserConfiguration(parse);
sempPrintParserConfiguration(parse, &Serial);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Examples/RTCM_Test/RTCM_Test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void processMessage(SEMP_PARSE_STATE *parse, uint16_t type)
{
displayOnce = false;
Serial.println();
sempPrintParserConfiguration(parse);
sempPrintParserConfiguration(parse, &Serial);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Examples/UBLOX_Test/UBLOX_Test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void processMessage(SEMP_PARSE_STATE *parse, uint16_t type)
{
displayOnce = false;
Serial.println();
sempPrintParserConfiguration(parse);
sempPrintParserConfiguration(parse, &Serial);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
SparkFun Unicore test example sketch
SparkFun Unicore binary test example sketch

License: MIT. Please see LICENSE.md for more details
*/
Expand All @@ -14,13 +14,13 @@
// Build the table listing all of the parsers
SEMP_PARSE_ROUTINE const parserTable[] =
{
sempUnicorePreamble
sempUnicoreBinaryPreamble
};
const int parserCount = sizeof(parserTable) / sizeof(parserTable[0]);

const char * const parserNames[] =
{
"Unicore parser"
"Unicore binary parser"
};
const int parserNameCount = sizeof(parserNames) / sizeof(parserNames[0]);

Expand Down Expand Up @@ -180,7 +180,7 @@ void processMessage(SEMP_PARSE_STATE *parse, uint16_t type)
{
displayOnce = false;
Serial.println();
sempPrintParserConfiguration(parse);
sempPrintParserConfiguration(parse, &Serial);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Examples/User_Parser/User_Parser.ino
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void userMessage(SEMP_PARSE_STATE *parse, uint16_t type)
{
displayOnce = false;
Serial.println();
sempPrintParserConfiguration(parse);
sempPrintParserConfiguration(parse, &Serial);
}
}

Expand Down
Loading