Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
examples/*/build

83 changes: 83 additions & 0 deletions check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash
#
# check.sh
# Script to verify example builds
########################################################################
set -e
#set -o verbose
#set -o xtrace

# Base_Test
cd examples/Base_Test
make clean
make
make clean

# Mixed_Parser
cd ../Mixed_Parser
make clean
make
make clean

# Multiple_Parsers
cd ../Multiple_Parsers
make clean
make
make clean

# NMEA_Test
cd ../NMEA_Test
make clean
make
make clean

# RTCM_Test
cd ../RTCM_Test
make clean
make
make clean

# SBF_in_SPARTN_Test
cd ../SBF_in_SPARTN_Test
make clean
make
make clean

# SBF_Test
cd ../SBF_Test
make clean
make
make clean

# SPARTN_Test
cd ../SPARTN_Test
make clean
make
make clean

# UBLOX_Test
cd ../UBLOX_Test
make clean
make
make clean

# Unicore_Binary_Test
cd ../Unicore_Binary_Test
make clean
make
make clean

# Unicore_Hash_Test
cd ../Unicore_Hash_Test
make clean
make
make clean

# User_Parser_Test
cd ../User_Parser
make clean
make
make clean

# Return to origin directory
cd ../..
95 changes: 14 additions & 81 deletions examples/Base_Test/Base_Test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
License: MIT. Please see LICENSE.md for more details
*/

#include <SparkFun_Extensible_Message_Parser.h> //http://librarymanager/All#SparkFun_Extensible_Message_Parser
#include "No_Parser.h"

#include "../Common/dumpBuffer.ino"
#include "../Common/reportFatalError.ino"

//----------------------------------------
// Constants
Expand All @@ -17,17 +20,6 @@ const uint8_t rawDataStream[] =

#define RAW_DATA_BYTES sizeof(rawDataStream)

// Forward routine declarations
bool noParserPreamble(SEMP_PARSE_STATE *parse, uint8_t data);

// Build the description for the No parser
SEMP_PARSER_DESCRIPTION noParserDescription =
{
"No parser", // parserName
noParserPreamble, // preamble
0, // scratchPadBytes
};

// Build the table listing all of the parsers
SEMP_PARSER_DESCRIPTION * parserTable[] =
{
Expand All @@ -42,10 +34,13 @@ const int parserCount = sizeof(parserTable) / sizeof(parserTable[0]);
uint32_t dataOffset;
SEMP_PARSE_STATE *parse;

//------------------------------------------------------------------------------
// Test routines
//------------------------------------------------------------------------------

//----------------------------------------
// Test routine
// Application entry point used to initialize the system
//----------------------------------------

void setup()
{
uint8_t * buffer;
Expand Down Expand Up @@ -138,19 +133,17 @@ void setup()
Serial.printf("All done\r\n");
}

//----------------------------------------
// Main loop processing, repeatedly called after system is initialized by setup
//----------------------------------------
void loop()
{
}

// Check for the preamble
bool noParserPreamble(SEMP_PARSE_STATE *parse, uint8_t data)
{
// Preamble not found
return false;
}

//----------------------------------------
// Call back from within parser, for end of message
// Process a complete message incoming from parser
//----------------------------------------
void processMessage(SEMP_PARSE_STATE *parse, uint16_t type)
{
static bool displayOnce = true;
Expand All @@ -171,63 +164,3 @@ void processMessage(SEMP_PARSE_STATE *parse, uint16_t type)
sempPrintParserConfiguration(parse, &Serial);
}
}

// Display the contents of a buffer
void dumpBuffer(uint8_t *buffer, uint16_t length)
{
int bytes;
uint8_t *end;
int index;
uint16_t offset;

end = &buffer[length];
offset = 0;
while (buffer < end)
{
// Determine the number of bytes to display on the line
bytes = end - buffer;
if (bytes > (16 - (offset & 0xf)))
bytes = 16 - (offset & 0xf);

// Display the offset
Serial.printf("0x%08lx: ", offset);

// Skip leading bytes
for (index = 0; index < (offset & 0xf); index++)
Serial.printf(" ");

// Display the data bytes
for (index = 0; index < bytes; index++)
Serial.printf("%02x ", buffer[index]);

// Separate the data bytes from the ASCII
for (; index < (16 - (offset & 0xf)); index++)
Serial.printf(" ");
Serial.printf(" ");

// Skip leading bytes
for (index = 0; index < (offset & 0xf); index++)
Serial.printf(" ");

// Display the ASCII values
for (index = 0; index < bytes; index++)
Serial.printf("%c", ((buffer[index] < ' ') || (buffer[index] >= 0x7f)) ? '.' : buffer[index]);
Serial.printf("\r\n");

// Set the next line of data
buffer += bytes;
offset += bytes;
}
}

// Print the error message every 15 seconds
void reportFatalError(const char *errorMsg)
{
while (1)
{
Serial.print("HALTED: ");
Serial.print(errorMsg);
Serial.println();
sleep(15);
}
}
74 changes: 74 additions & 0 deletions examples/Base_Test/No_Parser.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
No_Parser.cpp
SparkFun base test example sketch, verify it builds

License: MIT. Please see LICENSE.md for more details

Implement the "No_Parser"
*/

#include "No_Parser.h"

//------------------------------------------------------------------------------
// No_Parser routines
//
// The parser routines are placed in reverse order to define the routine before
// its use and eliminate forward declarations. Removing the forward declaration
// helps reduce the exposure of the routines to the application layer. The public
// data structures and routines are listed at the end of the file.
//------------------------------------------------------------------------------

//----------------------------------------
// Check for the preamble
//
// Inputs:
// parse: Address of a SEMP_PARSE_STATE structure
// data: First data byte in the stream of data to parse
//
// Outputs:
// Returns true if the No_Parser recgonizes the input and false
// if another parser should be used
//----------------------------------------
bool noParserPreamble(SEMP_PARSE_STATE *parse, uint8_t data)
{
if (data == 2)
{
parse->eomCallback(parse, parse->type);
parse->state = sempFirstByte;
return true;
}
// Preamble not found
return false;
}

//----------------------------------------
// Translate the state into a zero terminated state name string
//
// Inputs:
// parse: Address of a SEMP_PARSE_STATE structure
//
// Outputs
// Returns the address of the zero terminated state name string
//----------------------------------------
const char * noParserGetStateName(const SEMP_PARSE_STATE *parse)
{
return nullptr;
}

//------------------------------------------------------------------------------
// Public data and routines
//
// The following data structures and routines are listed in the .h file and are
// exposed to the SEMP routine and application layer.
//------------------------------------------------------------------------------

//----------------------------------------
// Describe the parser
//----------------------------------------
SEMP_PARSER_DESCRIPTION noParserDescription =
{
"No parser", // parserName
noParserPreamble, // preamble
0, // scratchPadBytes
0, // payloadOffset
};
21 changes: 21 additions & 0 deletions examples/Base_Test/No_Parser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
No_Parser.h

License: MIT. Please see LICENSE.md for more details

Declare the public data structures and routines for the "No_Parser"
*/

#ifndef __NO_PARSER_H__
#define __NO_PARSER_H__

#include <SparkFun_Extensible_Message_Parser.h> //http://librarymanager/All#SparkFun_Extensible_Message_Parser

//----------------------------------------
// Constants
//----------------------------------------

// No parser externals
extern SEMP_PARSER_DESCRIPTION noParserDescription;

#endif // __NO_PARSER_H__
Loading