Main Page | Data Structures | File List | Data Fields | Globals

nmeap.h File Reference

#include "nmeap_def.h"

Go to the source code of this file.

Data Structures

struct  nmeap_gga
struct  nmeap_rmc

Defines

#define NMEAP_MAX_SENTENCES   8
#define NMEAP_MAX_SENTENCE_NAME_LENGTH   5
#define NMEAP_MAX_SENTENCE_LENGTH   255
#define NMEAP_MAX_TOKENS   24
#define NMEAP_GPGGA   1
#define NMEAP_GPRMC   2
#define NMEAP_USER   100

Typedefs

typedef void(* nmeap_callout_t )(struct nmeap_context *context, void *sentence_data, void *user_data)
typedef int(* nmeap_sentence_parser_t )(struct nmeap_context *context, struct nmeap_sentence *sentence)
typedef nmeap_gga nmeap_gga_t
typedef nmeap_rmc nmeap_rmc_t

Functions

int nmeap_init (nmeap_context_t *context, void *user_data)
int nmeap_addParser (nmeap_context_t *context, const char *sentence_name, nmeap_sentence_parser_t sentence_parser, nmeap_callout_t sentence_callout, void *sentence_data)
int nmeap_parseBuffer (nmeap_context_t *context, const char *buffer, int *length)
int nmeap_parse (nmeap_context_t *context, char ch)
int nmeap_gpgga (nmeap_context_t *context, nmeap_sentence_t *sentence)
int nmeap_gprmc (nmeap_context_t *context, nmeap_sentence_t *sentence)
double nmeap_latitude (const char *plat, const char *phem)
double nmeap_longitude (const char *plat, const char *phem)


Define Documentation

#define NMEAP_GPGGA   1
 

#define NMEAP_GPRMC   2
 

#define NMEAP_MAX_SENTENCE_LENGTH   255
 

max length of a complete sentence. the standard says 82 bytes, but its probably better to go at least 128 since some units don't adhere to the 82 bytes especially for proprietary sentences

#define NMEAP_MAX_SENTENCE_NAME_LENGTH   5
 

length of sentence name. leave this at 5 unless you really know what you are doing

#define NMEAP_MAX_SENTENCES   8
 

maximum number of sentence parsers supported

#define NMEAP_MAX_TOKENS   24
 

max tokens in one sentence. 24 is enough for any standard sentence

#define NMEAP_USER   100
 

user defined parsers should make ID numbers using NMEAP_USER as the base value, plus some increment


Typedef Documentation

typedef void(* nmeap_callout_t)(struct nmeap_context *context,void *sentence_data,void *user_data)
 

sentence callout function type a callout is fired for each registered sentence type the callout gets the object context and a pointer to sentence specific data. the callout must cast the 'sentence_data' to the appropriate type for that callout

Parameters:
context nmea object context
sentence_data sentence specific data

typedef struct nmeap_gga nmeap_gga_t
 

typedef struct nmeap_rmc nmeap_rmc_t
 

typedef int(* nmeap_sentence_parser_t)(struct nmeap_context *context,struct nmeap_sentence *sentence)
 

sentence parser function type stored in the object context and called internally when the sentence name matches the specified value the callout gets the object context and a pointer to sentence specific data. the callout must cast the 'sentence_data' to the appropriate type for that callout

Parameters:
context nmea object context
sentence_data sentence specific data
Returns:
id of sentence (each sentence parser knows its own ID)


Function Documentation

int nmeap_addParser nmeap_context_t context,
const char *  sentence_name,
nmeap_sentence_parser_t  sentence_parser,
nmeap_callout_t  sentence_callout,
void *  sentence_data
 

register an NMEA sentence parser

Parameters:
context nmea object context
sentence_name string matching the sentence name for this parser. e.g. "GPGGA". not including the '$'
sentence_parser parser function for this sentence
sentence_callout callout triggered when this sentence is received and parsed. if null, no callout is triggered for this sentence
sentence_data user allocated sentence specific data defined by the application. the parser uses this data item to store the extracted data. This data object needs to persist over the life of the parser, so be careful if allocated on the stack.
Returns:
0 if registered ok, -1 if registration failed

int nmeap_gpgga nmeap_context_t context,
nmeap_sentence_t sentence
 

built-in parser for GGA sentences.

Parameters:
context nmea object context
sentence sentence object for this parser

int nmeap_gprmc nmeap_context_t context,
nmeap_sentence_t sentence
 

built-in parser for RMC sentences.

Parameters:
context nmea object context
sentence sentence object for this parser

int nmeap_init nmeap_context_t context,
void *  user_data
 

initialize an NMEA parser. call this function to initialize a user allocated context object

Parameters:
context nmea object context. allocated by user statically or dynamically.
user_data pointer to user defined data
Returns:
0 if ok, -1 if initialization failed

double nmeap_latitude const char *  plat,
const char *  phem
 

extract latitude from 2 tokens in ddmm.mmmm,h format.

Parameters:
plat pointer to token with numerical latitude
phem pointer to token with hemisphere
Returns:
latitude in degrees and fractional degrees

double nmeap_longitude const char *  plat,
const char *  phem
 

extract longitude from 2 tokens in ddmm.mmmm,h format.

Parameters:
plat pointer to token with numerical longitude
phem pointer to token with hemisphere
Returns:
longitude in degrees and fractional degrees

int nmeap_parse nmeap_context_t context,
char  ch
 

parse one character of nmea data.

Parameters:
context nmea object context
ch input character
Returns:
-1 if error, 0 if the data did not complete a sentence, sentence code if a sentence was found in the stream

int nmeap_parseBuffer nmeap_context_t context,
const char *  buffer,
int *  length
 

parse a buffer of nmea data.

Parameters:
context nmea object context
buffer buffer of input characters
length [in,out] pointer to length of buffer. on return, contains number of characters not used for the current sentence
Returns:
-1 if error, 0 if the data did not complete a sentence, sentence code if a sentence was found in the stream


Generated on Wed Mar 14 20:32:17 2007 for GloPosCom by doxygen 1.3.4