Commit ae33831f authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

Add nmealib files and test program

parent 33e53813
CHANGE LOG
version 0.5.3
- fixed time parse error (bug #1889477)
- renamed math.h to gmath.h
- excluded malloc.h header
- fixed sleep in samples for UNIX
- added "remake" target in Makefile
version 0.5.2
- fixed CRC error (bug #1833200)
version 0.5.1
- fixed elevation value type (bug #1832486)
- fixed parsing of GPRMC - nmea_GPRMC2info
version 0.5.0
- added nmea_distance_ellipsoid, nmea_move_horz_ellipsoid in math.h and sample (Thanks Thomas1970)
- fixed makefiles (Thanks for Sereg@ and Thomas1970)
- fixed inline functions in math.h
version 0.4.4
- fixed makefiles (Thanks for Sereg@ and Thomas1970)
version 0.4.3
- fixed bugs #1805550, #1780086, #1778485
- fixed parse VTG packet
This diff is collapsed.
CC = gcc
BIN = lib/libnmea.a
MODULES = generate generator parse parser tok context time info gmath sentence
SAMPLES = generate generator parse parse_file math
OBJ = $(MODULES:%=build/nmea_gcc/%.o)
LINKOBJ = $(OBJ) $(RES)
SMPLS = $(SAMPLES:%=samples_%)
SMPLOBJ = $(SAMPLES:%=samples/%/main.o)
INCS = -I include
LIBS = -Llib -lnmea -lm
.PHONY: all all-before all-after clean clean-custom doc
all: all-before $(BIN) samples all-after
all-before:
mkdir -p build/nmea_gcc
clean: clean-custom
rm -f $(LINKOBJ) $(BIN) $(SMPLOBJ) $(SMPLS)
doc:
$(MAKE) -C doc
remake: clean all
$(BIN): $(LINKOBJ)
ar rsc $@ $^
ranlib $@
build/nmea_gcc/%.o: src/%.c
$(CC) $(INCS) -c $< -o $@
samples: $(SMPLS)
samples_%: samples/%/main.o
$(CC) $< $(LIBS) -o build/$@
samples/%/main.o: samples/%/main.c
$(CC) $(INCS) -c $< -o $@
NMEA library
Disclaimer
The National Marine Electronics Association (NMEA) has developed a specification that defines the interface between various pieces of marine electronic equipment. The standard permits marine electronics to send information to computers and to other marine equipment.
Most computer programs that provide real time position information understand and expect data to be in NMEA format. This data includes the complete PVT (position, velocity, time) solution computed by the GPS receiver. The idea of NMEA is to send a line of data called a sentence that is totally self contained and independent from other sentences. All NMEA sentences is sequences of ACSII symbols begins with a '$' and ends with a carriage return/line feed sequence and can be no longer than 80 characters of visible text (plus the line terminators).
Introduction
We present library in 'C' programming language for work with NMEA protocol. Small and easy to use. The library build on different compilers under different platforms (see below). The code was tested in real projects. Just download and try...
Features
- Analysis NMEA sentences and granting GPS data in C structures
- Generate NMEA sentences
- Supported sentences: GPGGA, GPGSA, GPGSV, GPRMC, GPVTG
- Multilevel architecture of algorithms
- Additional functions of geographical mathematics and work with navigation data
Supported (tested) platforms
- Microsoft Windows (MS Visual Studio 8.0, GCC)
- Windows Mobile, Windows CE (MS Visual Studio 8.0)
- UNIX (GCC)
Licence: LGPL
doc: nmea.doxygen
doxygen $^
# Doxyfile 1.5.1-p1
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = NMEA
PROJECT_NUMBER = 0.5.3
OUTPUT_DIRECTORY = .
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = YES
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class" \
"The $name widget" \
"The $name file" \
is \
provides \
specifies \
contains \
represents \
a \
an \
the
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH = .
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
BUILTIN_STL_SUPPORT = NO
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = NO
HIDE_UNDOC_MEMBERS = YES
HIDE_UNDOC_CLASSES = YES
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = NO
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = NO
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ../src \
../include/nmea
FILE_PATTERNS = *.c \
*.h
RECURSIVE = NO
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = YES
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = NO
REFERENCES_RELATION = NO
REFERENCES_LINK_SOURCE = YES
USE_HTAGS = NO
VERBATIM_HEADERS = NO
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = YES
CHM_FILE = nmealib.chm
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = YES
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = NO
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = NO
CLASS_GRAPH = NO
COLLABORATION_GRAPH = NO
GROUP_GRAPHS = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = NO
INCLUDED_BY_GRAPH = NO
CALL_GRAPH = NO
CALLER_GRAPH = NO
GRAPHICAL_HIERARCHY = NO
DIRECTORY_GRAPH = NO
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 1000
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: config.h 17 2008-03-11 11:56:11Z xtimor $
*
*/
#ifndef __NMEA_CONFIG_H__
#define __NMEA_CONFIG_H__
#define NMEA_VERSION ("0.5.3")
#define NMEA_VERSION_MAJOR (0)
#define NMEA_VERSION_MINOR (5)
#define NMEA_VERSION_PATCH (3)
#define NMEA_CONVSTR_BUF (256)
#define NMEA_TIMEPARSE_BUF (256)
#if defined(WINCE) || defined(UNDER_CE)
# define NMEA_CE
#endif
#if defined(WIN32) || defined(NMEA_CE)
# define NMEA_WIN
#else
# define NMEA_UNI
#endif
#if defined(NMEA_WIN) && (_MSC_VER >= 1400)
# pragma warning(disable: 4996) /* declared deprecated */
#endif
#if defined(_MSC_VER)
# define NMEA_POSIX(x) _##x
# define NMEA_INLINE __inline
#else
# define NMEA_POSIX(x) x
# define NMEA_INLINE inline
#endif
#if !defined(NDEBUG) && !defined(NMEA_CE)
# include <assert.h>
# define NMEA_ASSERT(x) assert(x)
#else
# define NMEA_ASSERT(x)
#endif
#endif /* __NMEA_CONFIG_H__ */
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: context.h 4 2007-08-27 13:11:03Z xtimor $
*
*/
#ifndef __NMEA_CONTEXT_H__
#define __NMEA_CONTEXT_H__
#include "config.h"
#define NMEA_DEF_PARSEBUFF (1024)
#define NMEA_MIN_PARSEBUFF (256)
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*nmeaTraceFunc)(const char *str, int str_size);
typedef void (*nmeaErrorFunc)(const char *str, int str_size);
typedef struct _nmeaPROPERTY
{
nmeaTraceFunc trace_func;
nmeaErrorFunc error_func;
int parse_buff_size;
} nmeaPROPERTY;
nmeaPROPERTY * nmea_property();
void nmea_trace(const char *str, ...);
void nmea_trace_buff(const char *buff, int buff_size);
void nmea_error(const char *str, ...);
#ifdef __cplusplus
}
#endif
#endif /* __NMEA_CONTEXT_H__ */
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: generate.h 4 2007-08-27 13:11:03Z xtimor $
*
*/
#ifndef __NMEA_GENERATE_H__
#define __NMEA_GENERATE_H__
#include "sentence.h"
#ifdef __cplusplus
extern "C" {
#endif
int nmea_generate(
char *buff, int buff_sz, /* buffer */
const nmeaINFO *info, /* source info */
int generate_mask /* mask of sentence`s (e.g. GPGGA | GPGSA) */
);
int nmea_gen_GPGGA(char *buff, int buff_sz, nmeaGPGGA *pack);
int nmea_gen_GPGSA(char *buff, int buff_sz, nmeaGPGSA *pack);
int nmea_gen_GPGSV(char *buff, int buff_sz, nmeaGPGSV *pack);
int nmea_gen_GPRMC(char *buff, int buff_sz, nmeaGPRMC *pack);
int nmea_gen_GPVTG(char *buff, int buff_sz, nmeaGPVTG *pack);
void nmea_info2GPGGA(const nmeaINFO *info, nmeaGPGGA *pack);
void nmea_info2GPGSA(const nmeaINFO *info, nmeaGPGSA *pack);
void nmea_info2GPRMC(const nmeaINFO *info, nmeaGPRMC *pack);
void nmea_info2GPVTG(const nmeaINFO *info, nmeaGPVTG *pack);
int nmea_gsv_npack(int sat_count);
void nmea_info2GPGSV(const nmeaINFO *info, nmeaGPGSV *pack, int pack_idx);
#ifdef __cplusplus
}
#endif
#endif /* __NMEA_GENERATE_H__ */
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: generator.h 4 2007-08-27 13:11:03Z xtimor $
*
*/
#ifndef __NMEA_GENERATOR_H__
#define __NMEA_GENERATOR_H__
#include "info.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* high level
*/
struct _nmeaGENERATOR;
enum nmeaGENTYPE
{
NMEA_GEN_NOISE = 0,
NMEA_GEN_STATIC,
NMEA_GEN_ROTATE,
NMEA_GEN_SAT_STATIC,
NMEA_GEN_SAT_ROTATE,
NMEA_GEN_POS_RANDMOVE,
NMEA_GEN_LAST
};
struct _nmeaGENERATOR * nmea_create_generator(int type, nmeaINFO *info);
void nmea_destroy_generator(struct _nmeaGENERATOR *gen);
int nmea_generate_from(
char *buff, int buff_sz, /* buffer */
nmeaINFO *info, /* source info */
struct _nmeaGENERATOR *gen, /* generator */
int generate_mask /* mask of sentence`s (e.g. GPGGA | GPGSA) */
);
/*
* low level
*/
typedef int (*nmeaNMEA_GEN_INIT)(struct _nmeaGENERATOR *gen, nmeaINFO *info);
typedef int (*nmeaNMEA_GEN_LOOP)(struct _nmeaGENERATOR *gen, nmeaINFO *info);
typedef int (*nmeaNMEA_GEN_RESET)(struct _nmeaGENERATOR *gen, nmeaINFO *info);
typedef int (*nmeaNMEA_GEN_DESTROY)(struct _nmeaGENERATOR *gen);
typedef struct _nmeaGENERATOR
{
void *gen_data;
nmeaNMEA_GEN_INIT init_call;
nmeaNMEA_GEN_LOOP loop_call;
nmeaNMEA_GEN_RESET reset_call;
nmeaNMEA_GEN_DESTROY destroy_call;
struct _nmeaGENERATOR *next;
} nmeaGENERATOR;
int nmea_gen_init(nmeaGENERATOR *gen, nmeaINFO *info);
int nmea_gen_loop(nmeaGENERATOR *gen, nmeaINFO *info);
int nmea_gen_reset(nmeaGENERATOR *gen, nmeaINFO *info);
void nmea_gen_destroy(nmeaGENERATOR *gen);
void nmea_gen_add(nmeaGENERATOR *to, nmeaGENERATOR *gen);
#ifdef __cplusplus
}
#endif
#endif /* __NMEA_GENERATOR_H__ */
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: gmath.h 17 2008-03-11 11:56:11Z xtimor $
*
*/
#ifndef __NMEA_GMATH_H__
#define __NMEA_GMATH_H__
#include "info.h"
#define NMEA_PI (3.141592653589793) /**< PI value */
#define NMEA_PI180 (NMEA_PI / 180) /**< PI division by 180 */
#define NMEA_EARTHRADIUS_KM (6378) /**< Earth's mean radius in km */
#define NMEA_EARTHRADIUS_M (NMEA_EARTHRADIUS_KM * 1000) /**< Earth's mean radius in m */
#define NMEA_EARTH_SEMIMAJORAXIS_M (6378137.0) /**< Earth's semi-major axis in m according WGS84 */
#define NMEA_EARTH_SEMIMAJORAXIS_KM (NMEA_EARTHMAJORAXIS_KM / 1000) /**< Earth's semi-major axis in km according WGS 84 */
#define NMEA_EARTH_FLATTENING (1 / 298.257223563) /**< Earth's flattening according WGS 84 */
#define NMEA_DOP_FACTOR (5) /**< Factor for translating DOP to meters */
#ifdef __cplusplus
extern "C" {
#endif
/*
* degree VS radian
*/
double nmea_degree2radian(double val);
double nmea_radian2degree(double val);
/*
* NDEG (NMEA degree)
*/
double nmea_ndeg2degree(double val);
double nmea_degree2ndeg(double val);
double nmea_ndeg2radian(double val);
double nmea_radian2ndeg(double val);
/*
* DOP
*/
double nmea_calc_pdop(double hdop, double vdop);
double nmea_dop2meters(double dop);
double nmea_meters2dop(double meters);
/*
* positions work
*/
void nmea_info2pos(const nmeaINFO *info, nmeaPOS *pos);
void nmea_pos2info(const nmeaPOS *pos, nmeaINFO *info);
double nmea_distance(
const nmeaPOS *from_pos,
const nmeaPOS *to_pos
);
double nmea_distance_ellipsoid(
const nmeaPOS *from_pos,
const nmeaPOS *to_pos,
double *from_azimuth,
double *to_azimuth
);
int nmea_move_horz(
const nmeaPOS *start_pos,
nmeaPOS *end_pos,
double azimuth,
double distance
);
int nmea_move_horz_ellipsoid(
const nmeaPOS *start_pos,
nmeaPOS *end_pos,
double azimuth,
double distance,
double *end_azimuth
);
#ifdef __cplusplus
}
#endif
#endif /* __NMEA_GMATH_H__ */
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: info.h 10 2007-11-15 14:50:15Z xtimor $
*
*/
/*! \file */
#ifndef __NMEA_INFO_H__
#define __NMEA_INFO_H__
#include "time.h"
#define NMEA_SIG_BAD (0)
#define NMEA_SIG_LOW (1)
#define NMEA_SIG_MID (2)
#define NMEA_SIG_HIGH (3)
#define NMEA_FIX_BAD (1)
#define NMEA_FIX_2D (2)
#define NMEA_FIX_3D (3)
#define NMEA_MAXSAT (12)
#define NMEA_SATINPACK (4)
#define NMEA_NSATPACKS (NMEA_MAXSAT / NMEA_SATINPACK)
#define NMEA_DEF_LAT (5001.2621)
#define NMEA_DEF_LON (3613.0595)
#ifdef __cplusplus
extern "C" {
#endif
/**
* Position data in fractional degrees or radians
*/
typedef struct _nmeaPOS
{
double lat; /**< Latitude */
double lon; /**< Longitude */
} nmeaPOS;
/**
* Information about satellite
* @see nmeaSATINFO
* @see nmeaGPGSV
*/
typedef struct _nmeaSATELLITE
{
int id; /**< Satellite PRN number */
int in_use; /**< Used in position fix */
int elv; /**< Elevation in degrees, 90 maximum */
int azimuth; /**< Azimuth, degrees from true north, 000 to 359 */
int sig; /**< Signal, 00-99 dB */
} nmeaSATELLITE;
/**
* Information about all satellites in view
* @see nmeaINFO
* @see nmeaGPGSV
*/
typedef struct _nmeaSATINFO
{
int inuse; /**< Number of satellites in use (not those in view) */
int inview; /**< Total number of satellites in view */
nmeaSATELLITE sat[NMEA_MAXSAT]; /**< Satellites information */
} nmeaSATINFO;
/**
* Summary GPS information from all parsed packets,
* used also for generating NMEA stream
* @see nmea_parse
* @see nmea_GPGGA2info, nmea_...2info
*/
typedef struct _nmeaINFO
{
int smask; /**< Mask specifying types of packages from which data have been obtained */
nmeaTIME utc; /**< UTC of position */
int sig; /**< GPS quality indicator (0 = Invalid; 1 = Fix; 2 = Differential, 3 = Sensitive) */
int fix; /**< Operating mode, used for navigation (1 = Fix not available; 2 = 2D; 3 = 3D) */
double PDOP; /**< Position Dilution Of Precision */
double HDOP; /**< Horizontal Dilution Of Precision */
double VDOP; /**< Vertical Dilution Of Precision */
double lat; /**< Latitude in NDEG - +/-[degree][min].[sec/60] */
double lon; /**< Longitude in NDEG - +/-[degree][min].[sec/60] */
double elv; /**< Antenna altitude above/below mean sea level (geoid) in meters */
double speed; /**< Speed over the ground in kilometers/hour */
double direction; /**< Track angle in degrees True */
double declination; /**< Magnetic variation degrees (Easterly var. subtracts from true course) */
nmeaSATINFO satinfo; /**< Satellites information */
} nmeaINFO;
void nmea_zero_INFO(nmeaINFO *info);
#ifdef __cplusplus
}
#endif
#endif /* __NMEA_INFO_H__ */
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: nmea.h 17 2008-03-11 11:56:11Z xtimor $
*
*/
#ifndef __NMEA_H__
#define __NMEA_H__
#include "./config.h"
#include "./units.h"
#include "./gmath.h"
#include "./info.h"
#include "./sentence.h"
#include "./generate.h"
#include "./generator.h"
#include "./parse.h"
#include "./parser.h"
#include "./context.h"
#endif /* __NMEA_H__ */
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: parse.h 4 2007-08-27 13:11:03Z xtimor $
*
*/
#ifndef __NMEA_PARSE_H__
#define __NMEA_PARSE_H__
#include "sentence.h"
#ifdef __cplusplus
extern "C" {
#endif
int nmea_pack_type(const char *buff, int buff_sz);
int nmea_find_tail(const char *buff, int buff_sz, int *res_crc);
int nmea_parse_GPGGA(const char *buff, int buff_sz, nmeaGPGGA *pack);
int nmea_parse_GPGSA(const char *buff, int buff_sz, nmeaGPGSA *pack);
int nmea_parse_GPGSV(const char *buff, int buff_sz, nmeaGPGSV *pack);
int nmea_parse_GPRMC(const char *buff, int buff_sz, nmeaGPRMC *pack);
int nmea_parse_GPVTG(const char *buff, int buff_sz, nmeaGPVTG *pack);
void nmea_GPGGA2info(nmeaGPGGA *pack, nmeaINFO *info);
void nmea_GPGSA2info(nmeaGPGSA *pack, nmeaINFO *info);
void nmea_GPGSV2info(nmeaGPGSV *pack, nmeaINFO *info);
void nmea_GPRMC2info(nmeaGPRMC *pack, nmeaINFO *info);
void nmea_GPVTG2info(nmeaGPVTG *pack, nmeaINFO *info);
#ifdef __cplusplus
}
#endif
#endif /* __NMEA_PARSE_H__ */
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: parser.h 4 2007-08-27 13:11:03Z xtimor $
*
*/
#ifndef __NMEA_PARSER_H__
#define __NMEA_PARSER_H__
#include "info.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* high level
*/
typedef struct _nmeaPARSER
{
void *top_node;
void *end_node;
unsigned char *buffer;
int buff_size;
int buff_use;
} nmeaPARSER;
int nmea_parser_init(nmeaPARSER *parser);
void nmea_parser_destroy(nmeaPARSER *parser);
int nmea_parse(
nmeaPARSER *parser,
const char *buff, int buff_sz,
nmeaINFO *info
);
/*
* low level
*/
int nmea_parser_push(nmeaPARSER *parser, const char *buff, int buff_sz);
int nmea_parser_top(nmeaPARSER *parser);
int nmea_parser_pop(nmeaPARSER *parser, void **pack_ptr);
int nmea_parser_peek(nmeaPARSER *parser, void **pack_ptr);
int nmea_parser_drop(nmeaPARSER *parser);
int nmea_parser_buff_clear(nmeaPARSER *parser);
int nmea_parser_queue_clear(nmeaPARSER *parser);
#ifdef __cplusplus
}
#endif
#endif /* __NMEA_PARSER_H__ */
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: sentence.h 17 2008-03-11 11:56:11Z xtimor $
*
*/
/*! \file */
#ifndef __NMEA_SENTENCE_H__
#define __NMEA_SENTENCE_H__
#include "info.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* NMEA packets type which parsed and generated by library
*/
enum nmeaPACKTYPE
{
GPNON = 0x0000, /**< Unknown packet type. */
GPGGA = 0x0001, /**< GGA - Essential fix data which provide 3D location and accuracy data. */
GPGSA = 0x0002, /**< GSA - GPS receiver operating mode, SVs used for navigation, and DOP values. */
GPGSV = 0x0004, /**< GSV - Number of SVs in view, PRN numbers, elevation, azimuth & SNR values. */
GPRMC = 0x0008, /**< RMC - Recommended Minimum Specific GPS/TRANSIT Data. */
GPVTG = 0x0010 /**< VTG - Actual track made good and speed over ground. */
};
/**
* GGA packet information structure (Global Positioning System Fix Data)
*/
typedef struct _nmeaGPGGA
{
nmeaTIME utc; /**< UTC of position (just time) */
double lat; /**< Latitude in NDEG - [degree][min].[sec/60] */
char ns; /**< [N]orth or [S]outh */
double lon; /**< Longitude in NDEG - [degree][min].[sec/60] */
char ew; /**< [E]ast or [W]est */
int sig; /**< GPS quality indicator (0 = Invalid; 1 = Fix; 2 = Differential, 3 = Sensitive) */
int satinuse; /**< Number of satellites in use (not those in view) */
double HDOP; /**< Horizontal dilution of precision */
double elv; /**< Antenna altitude above/below mean sea level (geoid) */
char elv_units; /**< [M]eters (Antenna height unit) */
double diff; /**< Geoidal separation (Diff. between WGS-84 earth ellipsoid and mean sea level. '-' = geoid is below WGS-84 ellipsoid) */
char diff_units; /**< [M]eters (Units of geoidal separation) */
double dgps_age; /**< Time in seconds since last DGPS update */
int dgps_sid; /**< DGPS station ID number */
} nmeaGPGGA;
/**
* GSA packet information structure (Satellite status)
*/
typedef struct _nmeaGPGSA
{
char fix_mode; /**< Mode (M = Manual, forced to operate in 2D or 3D; A = Automatic, 3D/2D) */
int fix_type; /**< Type, used for navigation (1 = Fix not available; 2 = 2D; 3 = 3D) */
int sat_prn[NMEA_MAXSAT]; /**< PRNs of satellites used in position fix (null for unused fields) */
double PDOP; /**< Dilution of precision */
double HDOP; /**< Horizontal dilution of precision */
double VDOP; /**< Vertical dilution of precision */
} nmeaGPGSA;
/**
* GSV packet information structure (Satellites in view)
*/
typedef struct _nmeaGPGSV
{
int pack_count; /**< Total number of messages of this type in this cycle */
int pack_index; /**< Message number */
int sat_count; /**< Total number of satellites in view */
nmeaSATELLITE sat_data[NMEA_SATINPACK];
} nmeaGPGSV;
/**
* RMC packet information structure (Recommended Minimum sentence C)
*/
typedef struct _nmeaGPRMC
{
nmeaTIME utc; /**< UTC of position */
char status; /**< Status (A = active or V = void) */
double lat; /**< Latitude in NDEG - [degree][min].[sec/60] */
char ns; /**< [N]orth or [S]outh */
double lon; /**< Longitude in NDEG - [degree][min].[sec/60] */
char ew; /**< [E]ast or [W]est */
double speed; /**< Speed over the ground in knots */
double direction; /**< Track angle in degrees True */
double declination; /**< Magnetic variation degrees (Easterly var. subtracts from true course) */
char declin_ew; /**< [E]ast or [W]est */
char mode; /**< Mode indicator of fix type (A = autonomous, D = differential, E = estimated, N = not valid, S = simulator) */
} nmeaGPRMC;
/**
* VTG packet information structure (Track made good and ground speed)
*/
typedef struct _nmeaGPVTG
{
double dir; /**< True track made good (degrees) */
char dir_t; /**< Fixed text 'T' indicates that track made good is relative to true north */
double dec; /**< Magnetic track made good */
char dec_m; /**< Fixed text 'M' */
double spn; /**< Ground speed, knots */
char spn_n; /**< Fixed text 'N' indicates that speed over ground is in knots */
double spk; /**< Ground speed, kilometers per hour */
char spk_k; /**< Fixed text 'K' indicates that speed over ground is in kilometers/hour */
} nmeaGPVTG;
void nmea_zero_GPGGA(nmeaGPGGA *pack);
void nmea_zero_GPGSA(nmeaGPGSA *pack);
void nmea_zero_GPGSV(nmeaGPGSV *pack);
void nmea_zero_GPRMC(nmeaGPRMC *pack);
void nmea_zero_GPVTG(nmeaGPVTG *pack);
#ifdef __cplusplus
}
#endif
#endif /* __NMEA_SENTENCE_H__ */
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: time.h 4 2007-08-27 13:11:03Z xtimor $
*
*/
/*! \file */
#ifndef __NMEA_TIME_H__
#define __NMEA_TIME_H__
#include "config.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Date and time data
* @see nmea_time_now
*/
typedef struct _nmeaTIME
{
int year; /**< Years since 1900 */
int mon; /**< Months since January - [0,11] */
int day; /**< Day of the month - [1,31] */
int hour; /**< Hours since midnight - [0,23] */
int min; /**< Minutes after the hour - [0,59] */
int sec; /**< Seconds after the minute - [0,59] */
int hsec; /**< Hundredth part of second - [0,99] */
} nmeaTIME;
/**
* \brief Get time now to nmeaTIME structure
*/
void nmea_time_now(nmeaTIME *t);
#ifdef __cplusplus
}
#endif
#endif /* __NMEA_TIME_H__ */
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: tok.h 4 2007-08-27 13:11:03Z xtimor $
*
*/
#ifndef __NMEA_TOK_H__
#define __NMEA_TOK_H__
#include "config.h"
#ifdef __cplusplus
extern "C" {
#endif
int nmea_calc_crc(const char *buff, int buff_sz);
int nmea_atoi(const char *str, int str_sz, int radix);
double nmea_atof(const char *str, int str_sz);
int nmea_printf(char *buff, int buff_sz, const char *format, ...);
int nmea_scanf(const char *buff, int buff_sz, const char *format, ...);
#ifdef __cplusplus
}
#endif
#endif /* __NMEA_TOK_H__ */
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: units.h 4 2007-08-27 13:11:03Z xtimor $
*
*/
#ifndef __NMEA_UNITS_H__
#define __NMEA_UNITS_H__
#include "config.h"
/*
* Distance units
*/
#define NMEA_TUD_YARDS (1.0936) /**< Yeards, meter * NMEA_TUD_YARDS = yard */
#define NMEA_TUD_KNOTS (1.852) /**< Knots, kilometer / NMEA_TUD_KNOTS = knot */
#define NMEA_TUD_MILES (1.609) /**< Miles, kilometer / NMEA_TUD_MILES = mile */
/*
* Speed units
*/
#define NMEA_TUS_MS (3.6) /**< Meters per seconds, (k/h) / NMEA_TUS_MS= (m/s) */
#endif /* __NMEA_UNITS_H__ */

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nmea", "src\nmea.vcproj", "{462522F4-3517-4507-A9C9-1D51DEBC4824}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "generate", "samples\generate\generate.vcproj", "{DE9B0EA5-9073-4055-8E81-2AF1C9230FA5}"
ProjectSection(ProjectDependencies) = postProject
{462522F4-3517-4507-A9C9-1D51DEBC4824} = {462522F4-3517-4507-A9C9-1D51DEBC4824}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "parse", "samples\parse\parse.vcproj", "{C2750C56-289A-47B9-8CCF-2E754D356D40}"
ProjectSection(ProjectDependencies) = postProject
{462522F4-3517-4507-A9C9-1D51DEBC4824} = {462522F4-3517-4507-A9C9-1D51DEBC4824}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "parse_file", "samples\parse_file\parse_file.vcproj", "{CBA61881-57F7-4798-9A54-DC25ED55A0CE}"
ProjectSection(ProjectDependencies) = postProject
{462522F4-3517-4507-A9C9-1D51DEBC4824} = {462522F4-3517-4507-A9C9-1D51DEBC4824}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "generator", "samples\generator\generator.vcproj", "{3F30D9B1-0B70-4D56-9BF1-B813E2F9D9D6}"
ProjectSection(ProjectDependencies) = postProject
{462522F4-3517-4507-A9C9-1D51DEBC4824} = {462522F4-3517-4507-A9C9-1D51DEBC4824}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{36908705-F3E6-4F39-BA17-562767076DCA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "math", "samples\math\math.vcproj", "{69B5B81E-351D-48E2-B883-AD1BB95301D4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Pocket PC 2003 (ARMV4) = Debug|Pocket PC 2003 (ARMV4)
Debug|Win32 = Debug|Win32
Release|Pocket PC 2003 (ARMV4) = Release|Pocket PC 2003 (ARMV4)
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{462522F4-3517-4507-A9C9-1D51DEBC4824}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Pocket PC 2003 (ARMV4)
{462522F4-3517-4507-A9C9-1D51DEBC4824}.Debug|Pocket PC 2003 (ARMV4).Build.0 = Debug|Pocket PC 2003 (ARMV4)
{462522F4-3517-4507-A9C9-1D51DEBC4824}.Debug|Win32.ActiveCfg = Debug|Win32
{462522F4-3517-4507-A9C9-1D51DEBC4824}.Debug|Win32.Build.0 = Debug|Win32
{462522F4-3517-4507-A9C9-1D51DEBC4824}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4)
{462522F4-3517-4507-A9C9-1D51DEBC4824}.Release|Pocket PC 2003 (ARMV4).Build.0 = Release|Pocket PC 2003 (ARMV4)
{462522F4-3517-4507-A9C9-1D51DEBC4824}.Release|Win32.ActiveCfg = Release|Win32
{462522F4-3517-4507-A9C9-1D51DEBC4824}.Release|Win32.Build.0 = Release|Win32
{DE9B0EA5-9073-4055-8E81-2AF1C9230FA5}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Pocket PC 2003 (ARMV4)
{DE9B0EA5-9073-4055-8E81-2AF1C9230FA5}.Debug|Win32.ActiveCfg = Debug|Win32
{DE9B0EA5-9073-4055-8E81-2AF1C9230FA5}.Debug|Win32.Build.0 = Debug|Win32
{DE9B0EA5-9073-4055-8E81-2AF1C9230FA5}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4)
{DE9B0EA5-9073-4055-8E81-2AF1C9230FA5}.Release|Win32.ActiveCfg = Release|Win32
{DE9B0EA5-9073-4055-8E81-2AF1C9230FA5}.Release|Win32.Build.0 = Release|Win32
{C2750C56-289A-47B9-8CCF-2E754D356D40}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Pocket PC 2003 (ARMV4)
{C2750C56-289A-47B9-8CCF-2E754D356D40}.Debug|Win32.ActiveCfg = Debug|Win32
{C2750C56-289A-47B9-8CCF-2E754D356D40}.Debug|Win32.Build.0 = Debug|Win32
{C2750C56-289A-47B9-8CCF-2E754D356D40}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4)
{C2750C56-289A-47B9-8CCF-2E754D356D40}.Release|Win32.ActiveCfg = Release|Win32
{C2750C56-289A-47B9-8CCF-2E754D356D40}.Release|Win32.Build.0 = Release|Win32
{CBA61881-57F7-4798-9A54-DC25ED55A0CE}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Pocket PC 2003 (ARMV4)
{CBA61881-57F7-4798-9A54-DC25ED55A0CE}.Debug|Win32.ActiveCfg = Debug|Win32
{CBA61881-57F7-4798-9A54-DC25ED55A0CE}.Debug|Win32.Build.0 = Debug|Win32
{CBA61881-57F7-4798-9A54-DC25ED55A0CE}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4)
{CBA61881-57F7-4798-9A54-DC25ED55A0CE}.Release|Win32.ActiveCfg = Release|Win32
{CBA61881-57F7-4798-9A54-DC25ED55A0CE}.Release|Win32.Build.0 = Release|Win32
{3F30D9B1-0B70-4D56-9BF1-B813E2F9D9D6}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Pocket PC 2003 (ARMV4)
{3F30D9B1-0B70-4D56-9BF1-B813E2F9D9D6}.Debug|Win32.ActiveCfg = Debug|Win32
{3F30D9B1-0B70-4D56-9BF1-B813E2F9D9D6}.Debug|Win32.Build.0 = Debug|Win32
{3F30D9B1-0B70-4D56-9BF1-B813E2F9D9D6}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4)
{3F30D9B1-0B70-4D56-9BF1-B813E2F9D9D6}.Release|Win32.ActiveCfg = Release|Win32
{3F30D9B1-0B70-4D56-9BF1-B813E2F9D9D6}.Release|Win32.Build.0 = Release|Win32
{69B5B81E-351D-48E2-B883-AD1BB95301D4}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|Pocket PC 2003 (ARMV4)
{69B5B81E-351D-48E2-B883-AD1BB95301D4}.Debug|Win32.ActiveCfg = Debug|Win32
{69B5B81E-351D-48E2-B883-AD1BB95301D4}.Debug|Win32.Build.0 = Debug|Win32
{69B5B81E-351D-48E2-B883-AD1BB95301D4}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|Pocket PC 2003 (ARMV4)
{69B5B81E-351D-48E2-B883-AD1BB95301D4}.Release|Win32.ActiveCfg = Release|Win32
{69B5B81E-351D-48E2-B883-AD1BB95301D4}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{C2750C56-289A-47B9-8CCF-2E754D356D40} = {36908705-F3E6-4F39-BA17-562767076DCA}
{CBA61881-57F7-4798-9A54-DC25ED55A0CE} = {36908705-F3E6-4F39-BA17-562767076DCA}
{3F30D9B1-0B70-4D56-9BF1-B813E2F9D9D6} = {36908705-F3E6-4F39-BA17-562767076DCA}
{DE9B0EA5-9073-4055-8E81-2AF1C9230FA5} = {36908705-F3E6-4F39-BA17-562767076DCA}
{69B5B81E-351D-48E2-B883-AD1BB95301D4} = {36908705-F3E6-4F39-BA17-562767076DCA}
EndGlobalSection
GlobalSection(DPCodeReviewSolutionGUID) = preSolution
DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="generate"
ProjectGUID="{DE9B0EA5-9073-4055-8E81-2AF1C9230FA5}"
RootNamespace="nmea"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="Pocket PC 2003 (ARMV4)"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
ExceptionHandling="0"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea_d.lib"
OutputFile="$(OutDir)\$(ProjectName)_d.exe"
AdditionalLibraryDirectories="../../lib"
GenerateDebugInformation="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|Pocket PC 2003 (ARMV4)"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="1"
/>
<Tool
Name="VCCLCompilerTool"
ExecutionBucket="7"
Optimization="0"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
ExceptionHandling="0"
RuntimeLibrary="3"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
WarningLevel="4"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea_ppc_d.lib"
OutputFile="$(OutDir)\$(ProjectName)_d.exe"
AdditionalLibraryDirectories="../../lib"
GenerateDebugInformation="true"
TargetMachine="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCCodeSignTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
<DeploymentTool
ForceDirty="-1"
RemoteDirectory=""
RegisterOutput="0"
AdditionalFiles=""
/>
<DebuggerTool
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
ExceptionHandling="0"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea.lib"
AdditionalLibraryDirectories="../../lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Pocket PC 2003 (ARMV4)"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="1"
/>
<Tool
Name="VCCLCompilerTool"
ExecutionBucket="7"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
ExceptionHandling="0"
RuntimeLibrary="0"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
WarningLevel="4"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea_ppc.lib"
AdditionalLibraryDirectories="../../lib"
TargetMachine="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCCodeSignTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
<DeploymentTool
ForceDirty="-1"
RemoteDirectory=""
RegisterOutput="0"
AdditionalFiles=""
/>
<DebuggerTool
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\main.c"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
#include <nmea/nmea.h>
#include <stdio.h>
#ifdef NMEA_WIN
# include <windows.h>
#else
# include <unistd.h>
#endif
int main()
{
nmeaINFO info;
char buff[2048];
int gen_sz;
int it;
nmea_zero_INFO(&info);
info.sig = 3;
info.fix = 3;
info.lat = 5000.0;
info.lon = 3600.0;
info.speed = 2.14 * NMEA_TUS_MS;
info.elv = 10.86;
info.satinfo.inuse = 1;
info.satinfo.inview = 1;
/*
info.satinfo.sat[0].id = 1;
info.satinfo.sat[0].in_use = 1;
info.satinfo.sat[0].elv = 50;
info.satinfo.sat[0].azimuth = 0;
info.satinfo.sat[0].sig = 99;
*/
for(it = 0; it < 10; ++it)
{
gen_sz = nmea_generate(
&buff[0], 2048, &info,
GPGGA | GPGSA | GPGSV | GPRMC | GPVTG
);
buff[gen_sz] = 0;
printf("%s\n", &buff[0]);
#ifdef NMEA_WIN
Sleep(500);
#else
usleep(500000);
#endif
info.speed += .1;
}
return 0;
}
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="generator"
ProjectGUID="{3F30D9B1-0B70-4D56-9BF1-B813E2F9D9D6}"
RootNamespace="nmea"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="Pocket PC 2003 (ARMV4)"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
ExceptionHandling="0"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea_d.lib"
OutputFile="$(OutDir)\$(ProjectName)_d.exe"
AdditionalLibraryDirectories="../../lib"
GenerateDebugInformation="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|Pocket PC 2003 (ARMV4)"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="1"
/>
<Tool
Name="VCCLCompilerTool"
ExecutionBucket="7"
Optimization="0"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
ExceptionHandling="0"
RuntimeLibrary="3"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
WarningLevel="4"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea_ppc_d.lib"
OutputFile="$(OutDir)\$(ProjectName)_d.exe"
AdditionalLibraryDirectories="../../lib"
GenerateDebugInformation="true"
TargetMachine="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCCodeSignTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
<DeploymentTool
ForceDirty="-1"
RemoteDirectory=""
RegisterOutput="0"
AdditionalFiles=""
/>
<DebuggerTool
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
ExceptionHandling="0"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea.lib"
AdditionalLibraryDirectories="../../lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Pocket PC 2003 (ARMV4)"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="1"
/>
<Tool
Name="VCCLCompilerTool"
ExecutionBucket="7"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
ExceptionHandling="0"
RuntimeLibrary="0"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
WarningLevel="4"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea_ppc.lib"
AdditionalLibraryDirectories="../../lib"
TargetMachine="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCCodeSignTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
<DeploymentTool
ForceDirty="-1"
RemoteDirectory=""
RegisterOutput="0"
AdditionalFiles=""
/>
<DebuggerTool
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\main.c"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
#include <nmea/nmea.h>
#include <stdio.h>
#ifdef NMEA_WIN
# include <windows.h>
#else
# include <unistd.h>
#endif
int main()
{
nmeaGENERATOR *gen;
nmeaINFO info;
char buff[2048];
int gen_sz;
int it;
nmea_zero_INFO(&info);
if(0 == (gen = nmea_create_generator(NMEA_GEN_ROTATE, &info)))
return -1;
for(it = 0; it < 10000; ++it)
{
gen_sz = nmea_generate_from(
&buff[0], 2048, &info, gen,
GPGGA | GPGSA | GPGSV | GPRMC | GPVTG
);
buff[gen_sz] = 0;
printf("%s\n", &buff[0]);
#ifdef NMEA_WIN
Sleep(500);
#else
usleep(500000);
#endif
}
nmea_gen_destroy(gen);
return 0;
}
#include <nmea/nmea.h>
#include <string.h>
#include <stdio.h>
#define NUM_POINTS 4
int main()
{
const char *buff[] = {
"$GPRMC,213916.199,A,4221.0377,N,07102.9778,W,0.00,,010207,,,A*6A\r\n",
"$GPRMC,213917.199,A,4221.0510,N,07102.9549,W,0.23,175.43,010207,,,A*77\r\n",
"$GPRMC,213925.000,A,4221.1129,N,07102.9146,W,0.00,,010207,,,A*68\r\n",
"$GPRMC,111609.14,A,5001.27,N,3613.06,E,11.2,0.0,261206,0.0,E*50\r\n"
};
nmeaPOS pos[NUM_POINTS], pos_moved[NUM_POINTS][2];
double dist[NUM_POINTS][2];
double azimuth[NUM_POINTS][2], azimuth_moved[NUM_POINTS];
int result[2];
int it = 0;
nmeaPARSER parser;
nmea_parser_init(&parser);
for(it = 0; it < NUM_POINTS; ++it)
{
int result;
nmeaINFO info;
nmea_zero_INFO(&info);
result = nmea_parse(&parser, buff[it], (int)strlen(buff[it]), &info);
nmea_info2pos(&info, &pos[it]);
}
nmea_parser_destroy(&parser);
for(it = 0; it < NUM_POINTS; ++it)
{
dist[it][0] = nmea_distance(&pos[0], &pos[it]);
dist[it][1] = nmea_distance_ellipsoid(
&pos[0], &pos[it], &azimuth[it][0], &azimuth[it][1]
);
}
for(it = 0; it < NUM_POINTS; ++it)
{
result[0] = nmea_move_horz(&pos[0], &pos_moved[it][0], azimuth[it][0], dist[it][0]);
result[1] = nmea_move_horz_ellipsoid(
&pos[0], &pos_moved[it][1], azimuth[it][0], dist[it][0], &azimuth_moved[it]
);
}
/* Output of results */
printf("Coordinate points:\n");
for(it = 0; it < NUM_POINTS; ++it)
{
printf(
"P%d in radians: lat:%9.6lf lon:%9.6lf \tin degree: lat:%+010.6lf lon:%+011.6lf\n",
it, pos[it].lat, pos[it].lon, nmea_radian2degree(pos[it].lat), nmea_radian2degree(pos[it].lon)
);
}
printf("\nCalculation results:\n");
for(it = 0; it < NUM_POINTS; ++it)
{
printf("\n");
printf("Distance P0 to P%d\ton spheroid: %14.3lf m\n", it, dist[it][0]);
printf("Distance P0 to P%d\ton ellipsoid: %14.3lf m\n", it, dist[it][1]);
printf("Azimuth P0 to P%d\tat start: %8.3lf\tat end: %8.3lf\n", it, nmea_radian2degree(azimuth[it][0]), nmea_radian2degree(azimuth[it][1]));
printf("Move P0 to P%d\t \tAzimuth at end: %8.3lf\n", it, nmea_radian2degree(azimuth_moved[it]));
printf("Move P0 to P%d\ton spheroid: %3s lat:%+010.6lf lon:%+011.6lf\n", it, result[0] == 1 ? "OK" : "nOK", nmea_radian2degree(pos_moved[it][0].lat), nmea_radian2degree(pos_moved[it][0].lon));
printf("Move P0 to P%d\ton ellipsoid: %3s lat:%+010.6lf lon:%+011.6lf\n", it, result[0] == 1 ? "OK" : "nOK", nmea_radian2degree(pos_moved[it][1].lat), nmea_radian2degree(pos_moved[it][1].lon));
printf("Move P0 to P%d\toriginal: lat:%+010.6lf lon:%+011.6lf\n", it, nmea_radian2degree(pos[it].lat), nmea_radian2degree(pos[it].lon));
}
return 0;
}
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="math"
ProjectGUID="{69B5B81E-351D-48E2-B883-AD1BB95301D4}"
RootNamespace="nmea"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="Pocket PC 2003 (ARMV4)"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
ExceptionHandling="0"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea_d.lib"
OutputFile="$(OutDir)\$(ProjectName)_d.exe"
AdditionalLibraryDirectories="../../lib"
GenerateDebugInformation="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|Pocket PC 2003 (ARMV4)"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="1"
/>
<Tool
Name="VCCLCompilerTool"
ExecutionBucket="7"
Optimization="0"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
ExceptionHandling="0"
RuntimeLibrary="3"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
WarningLevel="4"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea_ppc_d.lib"
OutputFile="$(OutDir)\$(ProjectName)_d.exe"
AdditionalLibraryDirectories="../../lib"
GenerateDebugInformation="true"
EntryPointSymbol=""
TargetMachine="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCCodeSignTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
<DeploymentTool
ForceDirty="-1"
RemoteDirectory=""
RegisterOutput="0"
AdditionalFiles=""
/>
<DebuggerTool
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
ExceptionHandling="0"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea.lib"
AdditionalLibraryDirectories="../../lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Pocket PC 2003 (ARMV4)"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="1"
/>
<Tool
Name="VCCLCompilerTool"
ExecutionBucket="7"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
ExceptionHandling="0"
RuntimeLibrary="0"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
WarningLevel="4"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea_ppc.lib"
AdditionalLibraryDirectories="../../lib"
TargetMachine="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCCodeSignTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
<DeploymentTool
ForceDirty="-1"
RemoteDirectory=""
RegisterOutput="0"
AdditionalFiles=""
/>
<DebuggerTool
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\main.c"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
#include <nmea/nmea.h>
#include <string.h>
int main()
{
const char *buff[] = {
"$GPRMC,173843,A,3349.896,N,11808.521,W,000.0,360.0,230108,013.4,E*69\r\n",
"$GPGGA,111609.14,5001.27,N,3613.06,E,3,08,0.0,10.2,M,0.0,M,0.0,0000*70\r\n",
"$GPGSV,2,1,08,01,05,005,80,02,05,050,80,03,05,095,80,04,05,140,80*7f\r\n",
"$GPGSV,2,2,08,05,05,185,80,06,05,230,80,07,05,275,80,08,05,320,80*71\r\n",
"$GPGSA,A,3,01,02,03,04,05,06,07,08,00,00,00,00,0.0,0.0,0.0*3a\r\n",
"$GPRMC,111609.14,A,5001.27,N,3613.06,E,11.2,0.0,261206,0.0,E*50\r\n",
"$GPVTG,217.5,T,208.8,M,000.00,N,000.01,K*4C\r\n"
};
int it;
nmeaINFO info;
nmeaPARSER parser;
nmea_zero_INFO(&info);
nmea_parser_init(&parser);
for(it = 0; it < 6; ++it)
nmea_parse(&parser, buff[it], (int)strlen(buff[it]), &info);
nmea_parser_destroy(&parser);
return 0;
}
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="parse"
ProjectGUID="{C2750C56-289A-47B9-8CCF-2E754D356D40}"
RootNamespace="nmea"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="Pocket PC 2003 (ARMV4)"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
ExceptionHandling="0"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea_d.lib"
OutputFile="$(OutDir)\$(ProjectName)_d.exe"
AdditionalLibraryDirectories="../../lib"
GenerateDebugInformation="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|Pocket PC 2003 (ARMV4)"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="1"
/>
<Tool
Name="VCCLCompilerTool"
ExecutionBucket="7"
Optimization="0"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
ExceptionHandling="0"
RuntimeLibrary="3"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
WarningLevel="4"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea_ppc_d.lib"
OutputFile="$(OutDir)\$(ProjectName)_d.exe"
AdditionalLibraryDirectories="../../lib"
GenerateDebugInformation="true"
EntryPointSymbol=""
TargetMachine="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCCodeSignTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
<DeploymentTool
ForceDirty="-1"
RemoteDirectory=""
RegisterOutput="0"
AdditionalFiles=""
/>
<DebuggerTool
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
ExceptionHandling="0"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea.lib"
AdditionalLibraryDirectories="../../lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Pocket PC 2003 (ARMV4)"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="1"
/>
<Tool
Name="VCCLCompilerTool"
ExecutionBucket="7"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
ExceptionHandling="0"
RuntimeLibrary="0"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
WarningLevel="4"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea_ppc.lib"
AdditionalLibraryDirectories="../../lib"
TargetMachine="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCCodeSignTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
<DeploymentTool
ForceDirty="-1"
RemoteDirectory=""
RegisterOutput="0"
AdditionalFiles=""
/>
<DebuggerTool
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\main.c"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
This diff is collapsed.
#include <nmea/nmea.h>
#include <string.h>
#include <stdio.h>
#ifdef NMEA_WIN
# include <io.h>
#endif
void trace(const char *str, int str_size)
{
printf("Trace: ");
write(1, str, str_size);
printf("\n");
}
void error(const char *str, int str_size)
{
printf("Error: ");
write(1, str, str_size);
printf("\n");
}
int main()
{
nmeaINFO info;
nmeaPARSER parser;
FILE *file;
char buff[2048];
int size, it = 0;
nmeaPOS dpos;
file = fopen("gpslog.txt", "rb");
if(!file)
return -1;
nmea_property()->trace_func = &trace;
nmea_property()->error_func = &error;
nmea_zero_INFO(&info);
nmea_parser_init(&parser);
/*
while(1)
{
*/
while(!feof(file))
{
size = (int)fread(&buff[0], 1, 100, file);
nmea_parse(&parser, &buff[0], size, &info);
nmea_info2pos(&info, &dpos);
printf(
"%03d, Lat: %f, Lon: %f, Sig: %d, Fix: %d\n",
it++, dpos.lat, dpos.lon, info.sig, info.fix
);
}
fseek(file, 0, SEEK_SET);
/*
}
*/
nmea_parser_destroy(&parser);
fclose(file);
return 0;
}
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="parse_file"
ProjectGUID="{CBA61881-57F7-4798-9A54-DC25ED55A0CE}"
RootNamespace="nmea"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="Pocket PC 2003 (ARMV4)"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
ExceptionHandling="0"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea_d.lib"
OutputFile="$(OutDir)\$(ProjectName)_d.exe"
AdditionalLibraryDirectories="../../lib"
GenerateDebugInformation="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|Pocket PC 2003 (ARMV4)"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="1"
/>
<Tool
Name="VCCLCompilerTool"
ExecutionBucket="7"
Optimization="0"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
MinimalRebuild="true"
ExceptionHandling="0"
RuntimeLibrary="1"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
WarningLevel="4"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea_ppc_d.lib"
OutputFile="$(OutDir)\$(ProjectName)_d.exe"
AdditionalLibraryDirectories="../../lib"
GenerateDebugInformation="true"
EntryPointSymbol=""
TargetMachine="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCCodeSignTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
<DeploymentTool
ForceDirty="-1"
RemoteDirectory=""
RegisterOutput="0"
AdditionalFiles=""
/>
<DebuggerTool
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
ExceptionHandling="0"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea.lib"
AdditionalLibraryDirectories="../../lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Pocket PC 2003 (ARMV4)"
OutputDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
IntermediateDirectory="../../build/$(PlatformName)/$(ConfigurationName)/$(ProjectName)"
ConfigurationType="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="1"
/>
<Tool
Name="VCCLCompilerTool"
ExecutionBucket="7"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
ExceptionHandling="0"
RuntimeLibrary="0"
BufferSecurityCheck="false"
UsePrecompiledHeader="0"
WarningLevel="4"
DebugInformationFormat="3"
CompileAs="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="nmea_ppc.lib"
AdditionalLibraryDirectories="../../lib"
TargetMachine="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCCodeSignTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
<DeploymentTool
ForceDirty="-1"
RemoteDirectory=""
RegisterOutput="0"
AdditionalFiles=""
/>
<DebuggerTool
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\main.c"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: context.c 17 2008-03-11 11:56:11Z xtimor $
*
*/
#include "nmea/context.h"
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
nmeaPROPERTY * nmea_property()
{
static nmeaPROPERTY prop = {
0, 0, NMEA_DEF_PARSEBUFF
};
return &prop;
}
void nmea_trace(const char *str, ...)
{
int size;
va_list arg_list;
char buff[NMEA_DEF_PARSEBUFF];
nmeaTraceFunc func = nmea_property()->trace_func;
if(func)
{
va_start(arg_list, str);
size = NMEA_POSIX(vsnprintf)(&buff[0], NMEA_DEF_PARSEBUFF - 1, str, arg_list);
va_end(arg_list);
if(size > 0)
(*func)(&buff[0], size);
}
}
void nmea_trace_buff(const char *buff, int buff_size)
{
nmeaTraceFunc func = nmea_property()->trace_func;
if(func && buff_size)
(*func)(buff, buff_size);
}
void nmea_error(const char *str, ...)
{
int size;
va_list arg_list;
char buff[NMEA_DEF_PARSEBUFF];
nmeaErrorFunc func = nmea_property()->error_func;
if(func)
{
va_start(arg_list, str);
size = NMEA_POSIX(vsnprintf)(&buff[0], NMEA_DEF_PARSEBUFF - 1, str, arg_list);
va_end(arg_list);
if(size > 0)
(*func)(&buff[0], size);
}
}
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: generate.c 17 2008-03-11 11:56:11Z xtimor $
*
*/
#include "nmea/tok.h"
#include "nmea/sentence.h"
#include "nmea/generate.h"
#include "nmea/units.h"
#include <string.h>
#include <stdlib.h>
#include <math.h>
int nmea_gen_GPGGA(char *buff, int buff_sz, nmeaGPGGA *pack)
{
return nmea_printf(buff, buff_sz,
"$GPGGA,%02d%02d%02d.%02d,%07.4f,%C,%07.4f,%C,%1d,%02d,%03.1f,%03.1f,%C,%03.1f,%C,%03.1f,%04d",
pack->utc.hour, pack->utc.min, pack->utc.sec, pack->utc.hsec,
pack->lat, pack->ns, pack->lon, pack->ew,
pack->sig, pack->satinuse, pack->HDOP, pack->elv, pack->elv_units,
pack->diff, pack->diff_units, pack->dgps_age, pack->dgps_sid);
}
int nmea_gen_GPGSA(char *buff, int buff_sz, nmeaGPGSA *pack)
{
return nmea_printf(buff, buff_sz,
"$GPGSA,%C,%1d,%02d,%02d,%02d,%02d,%02d,%02d,%02d,%02d,%02d,%02d,%02d,%02d,%03.1f,%03.1f,%03.1f",
pack->fix_mode, pack->fix_type,
pack->sat_prn[0], pack->sat_prn[1], pack->sat_prn[2], pack->sat_prn[3], pack->sat_prn[4], pack->sat_prn[5],
pack->sat_prn[6], pack->sat_prn[7], pack->sat_prn[8], pack->sat_prn[9], pack->sat_prn[10], pack->sat_prn[11],
pack->PDOP, pack->HDOP, pack->VDOP);
}
int nmea_gen_GPGSV(char *buff, int buff_sz, nmeaGPGSV *pack)
{
return nmea_printf(buff, buff_sz,
"$GPGSV,%1d,%1d,%02d,"
"%02d,%02d,%03d,%02d,"
"%02d,%02d,%03d,%02d,"
"%02d,%02d,%03d,%02d,"
"%02d,%02d,%03d,%02d",
pack->pack_count, pack->pack_index + 1, pack->sat_count,
pack->sat_data[0].id, pack->sat_data[0].elv, pack->sat_data[0].azimuth, pack->sat_data[0].sig,
pack->sat_data[1].id, pack->sat_data[1].elv, pack->sat_data[1].azimuth, pack->sat_data[1].sig,
pack->sat_data[2].id, pack->sat_data[2].elv, pack->sat_data[2].azimuth, pack->sat_data[2].sig,
pack->sat_data[3].id, pack->sat_data[3].elv, pack->sat_data[3].azimuth, pack->sat_data[3].sig);
}
int nmea_gen_GPRMC(char *buff, int buff_sz, nmeaGPRMC *pack)
{
return nmea_printf(buff, buff_sz,
"$GPRMC,%02d%02d%02d.%02d,%C,%07.4f,%C,%07.4f,%C,%03.1f,%03.1f,%02d%02d%02d,%03.1f,%C,%C",
pack->utc.hour, pack->utc.min, pack->utc.sec, pack->utc.hsec,
pack->status, pack->lat, pack->ns, pack->lon, pack->ew,
pack->speed, pack->direction,
pack->utc.day, pack->utc.mon + 1, pack->utc.year - 100,
pack->declination, pack->declin_ew, pack->mode);
}
int nmea_gen_GPVTG(char *buff, int buff_sz, nmeaGPVTG *pack)
{
return nmea_printf(buff, buff_sz,
"$GPVTG,%.1f,%C,%.1f,%C,%.1f,%C,%.1f,%C",
pack->dir, pack->dir_t,
pack->dec, pack->dec_m,
pack->spn, pack->spn_n,
pack->spk, pack->spk_k);
}
void nmea_info2GPGGA(const nmeaINFO *info, nmeaGPGGA *pack)
{
nmea_zero_GPGGA(pack);
pack->utc = info->utc;
pack->lat = fabs(info->lat);
pack->ns = ((info->lat > 0)?'N':'S');
pack->lon = fabs(info->lon);
pack->ew = ((info->lon > 0)?'E':'W');
pack->sig = info->sig;
pack->satinuse = info->satinfo.inuse;
pack->HDOP = info->HDOP;
pack->elv = info->elv;
}
void nmea_info2GPGSA(const nmeaINFO *info, nmeaGPGSA *pack)
{
int it;
nmea_zero_GPGSA(pack);
pack->fix_type = info->fix;
pack->PDOP = info->PDOP;
pack->HDOP = info->HDOP;
pack->VDOP = info->VDOP;
for(it = 0; it < NMEA_MAXSAT; ++it)
{
pack->sat_prn[it] =
((info->satinfo.sat[it].in_use)?info->satinfo.sat[it].id:0);
}
}
int nmea_gsv_npack(int sat_count)
{
int pack_count = (int)ceil(((double)sat_count) / NMEA_SATINPACK);
if(0 == pack_count)
pack_count = 1;
return pack_count;
}
void nmea_info2GPGSV(const nmeaINFO *info, nmeaGPGSV *pack, int pack_idx)
{
int sit, pit;
nmea_zero_GPGSV(pack);
pack->sat_count = (info->satinfo.inview <= NMEA_MAXSAT)?info->satinfo.inview:NMEA_MAXSAT;
pack->pack_count = nmea_gsv_npack(pack->sat_count);
if(pack->pack_count == 0)
pack->pack_count = 1;
if(pack_idx >= pack->pack_count)
pack->pack_index = pack_idx % pack->pack_count;
else
pack->pack_index = pack_idx;
for(pit = 0, sit = pack->pack_index * NMEA_SATINPACK; pit < NMEA_SATINPACK; ++pit, ++sit)
pack->sat_data[pit] = info->satinfo.sat[sit];
}
void nmea_info2GPRMC(const nmeaINFO *info, nmeaGPRMC *pack)
{
nmea_zero_GPRMC(pack);
pack->utc = info->utc;
pack->status = ((info->sig > 0)?'A':'V');
pack->lat = fabs(info->lat);
pack->ns = ((info->lat > 0)?'N':'S');
pack->lon = fabs(info->lon);
pack->ew = ((info->lon > 0)?'E':'W');
pack->speed = info->speed / NMEA_TUD_KNOTS;
pack->direction = info->direction;
pack->declination = info->declination;
pack->declin_ew = 'E';
pack->mode = ((info->sig > 0)?'A':'N');
}
void nmea_info2GPVTG(const nmeaINFO *info, nmeaGPVTG *pack)
{
nmea_zero_GPVTG(pack);
pack->dir = info->direction;
pack->dec = info->declination;
pack->spn = info->speed / NMEA_TUD_KNOTS;
pack->spk = info->speed;
}
int nmea_generate(
char *buff, int buff_sz,
const nmeaINFO *info,
int generate_mask
)
{
int gen_count = 0, gsv_it, gsv_count;
int pack_mask = generate_mask;
nmeaGPGGA gga;
nmeaGPGSA gsa;
nmeaGPGSV gsv;
nmeaGPRMC rmc;
nmeaGPVTG vtg;
if(!buff)
return 0;
while(pack_mask)
{
if(pack_mask & GPGGA)
{
nmea_info2GPGGA(info, &gga);
gen_count += nmea_gen_GPGGA(buff + gen_count, buff_sz - gen_count, &gga);
pack_mask &= ~GPGGA;
}
else if(pack_mask & GPGSA)
{
nmea_info2GPGSA(info, &gsa);
gen_count += nmea_gen_GPGSA(buff + gen_count, buff_sz - gen_count, &gsa);
pack_mask &= ~GPGSA;
}
else if(pack_mask & GPGSV)
{
gsv_count = nmea_gsv_npack(info->satinfo.inview);
for(gsv_it = 0; gsv_it < gsv_count && buff_sz - gen_count > 0; ++gsv_it)
{
nmea_info2GPGSV(info, &gsv, gsv_it);
gen_count += nmea_gen_GPGSV(buff + gen_count, buff_sz - gen_count, &gsv);
}
pack_mask &= ~GPGSV;
}
else if(pack_mask & GPRMC)
{
nmea_info2GPRMC(info, &rmc);
gen_count += nmea_gen_GPRMC(buff + gen_count, buff_sz - gen_count, &rmc);
pack_mask &= ~GPRMC;
}
else if(pack_mask & GPVTG)
{
nmea_info2GPVTG(info, &vtg);
gen_count += nmea_gen_GPVTG(buff + gen_count, buff_sz - gen_count, &vtg);
pack_mask &= ~GPVTG;
}
else
break;
if(buff_sz - gen_count <= 0)
break;
}
return gen_count;
}
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: generator.c 17 2008-03-11 11:56:11Z xtimor $
*
*/
#include "nmea/gmath.h"
#include "nmea/generate.h"
#include "nmea/generator.h"
#include "nmea/context.h"
#include <string.h>
#include <stdlib.h>
#if defined(NMEA_WIN) && defined(_MSC_VER)
# pragma warning(disable: 4100) /* unreferenced formal parameter */
#endif
double nmea_random(double min, double max)
{
static double rand_max = RAND_MAX;
double rand_val = rand();
double bounds = max - min;
return min + (rand_val * bounds) / rand_max;
}
/*
* low level
*/
int nmea_gen_init(nmeaGENERATOR *gen, nmeaINFO *info)
{
int RetVal = 1; int smask = info->smask;
nmeaGENERATOR *igen = gen;
nmea_zero_INFO(info);
info->smask = smask;
info->lat = NMEA_DEF_LAT;
info->lon = NMEA_DEF_LON;
while(RetVal && igen)
{
if(igen->init_call)
RetVal = (*igen->init_call)(igen, info);
igen = igen->next;
}
return RetVal;
}
int nmea_gen_loop(nmeaGENERATOR *gen, nmeaINFO *info)
{
int RetVal = 1;
if(gen->loop_call)
RetVal = (*gen->loop_call)(gen, info);
if(RetVal && gen->next)
RetVal = nmea_gen_loop(gen->next, info);
return RetVal;
}
int nmea_gen_reset(nmeaGENERATOR *gen, nmeaINFO *info)
{
int RetVal = 1;
if(gen->reset_call)
RetVal = (*gen->reset_call)(gen, info);
return RetVal;
}
void nmea_gen_destroy(nmeaGENERATOR *gen)
{
if(gen->next)
{
nmea_gen_destroy(gen->next);
gen->next = 0;
}
if(gen->destroy_call)
(*gen->destroy_call)(gen);
free(gen);
}
void nmea_gen_add(nmeaGENERATOR *to, nmeaGENERATOR *gen)
{
if(to->next)
nmea_gen_add(to->next, gen);
else
to->next = gen;
}
int nmea_generate_from(
char *buff, int buff_sz,
nmeaINFO *info,
nmeaGENERATOR *gen,
int generate_mask
)
{
int retval;
if(0 != (retval = nmea_gen_loop(gen, info)))
retval = nmea_generate(buff, buff_sz, info, generate_mask);
return retval;
}
/*
* NOISE generator
*/
int nmea_igen_noise_init(nmeaGENERATOR *gen, nmeaINFO *info)
{
return 1;
}
int nmea_igen_noise_loop(nmeaGENERATOR *gen, nmeaINFO *info)
{
int it;
int in_use;
info->sig = (int)nmea_random(1, 3);
info->PDOP = nmea_random(0, 9);
info->HDOP = nmea_random(0, 9);
info->VDOP = nmea_random(0, 9);
info->fix = (int)nmea_random(2, 3);
info->lat = nmea_random(0, 100);
info->lon = nmea_random(0, 100);
info->speed = nmea_random(0, 100);
info->direction = nmea_random(0, 360);
info->declination = nmea_random(0, 360);
info->elv = (int)nmea_random(-100, 100);
info->satinfo.inuse = 0;
info->satinfo.inview = 0;
for(it = 0; it < 12; ++it)
{
info->satinfo.sat[it].id = it;
info->satinfo.sat[it].in_use = in_use = (int)nmea_random(0, 3);
info->satinfo.sat[it].elv = (int)nmea_random(0, 90);
info->satinfo.sat[it].azimuth = (int)nmea_random(0, 359);
info->satinfo.sat[it].sig = (int)(in_use?nmea_random(40, 99):nmea_random(0, 40));
if(in_use)
info->satinfo.inuse++;
if(info->satinfo.sat[it].sig > 0)
info->satinfo.inview++;
}
return 1;
}
int nmea_igen_noise_reset(nmeaGENERATOR *gen, nmeaINFO *info)
{
return 1;
}
/*
* STATIC generator
*/
int nmea_igen_static_loop(nmeaGENERATOR *gen, nmeaINFO *info)
{
nmea_time_now(&info->utc);
return 1;
};
int nmea_igen_static_reset(nmeaGENERATOR *gen, nmeaINFO *info)
{
info->satinfo.inuse = 4;
info->satinfo.inview = 4;
info->satinfo.sat[0].id = 1;
info->satinfo.sat[0].in_use = 1;
info->satinfo.sat[0].elv = 50;
info->satinfo.sat[0].azimuth = 0;
info->satinfo.sat[0].sig = 99;
info->satinfo.sat[1].id = 2;
info->satinfo.sat[1].in_use = 1;
info->satinfo.sat[1].elv = 50;
info->satinfo.sat[1].azimuth = 90;
info->satinfo.sat[1].sig = 99;
info->satinfo.sat[2].id = 3;
info->satinfo.sat[2].in_use = 1;
info->satinfo.sat[2].elv = 50;
info->satinfo.sat[2].azimuth = 180;
info->satinfo.sat[2].sig = 99;
info->satinfo.sat[3].id = 4;
info->satinfo.sat[3].in_use = 1;
info->satinfo.sat[3].elv = 50;
info->satinfo.sat[3].azimuth = 270;
info->satinfo.sat[3].sig = 99;
return 1;
}
int nmea_igen_static_init(nmeaGENERATOR *gen, nmeaINFO *info)
{
info->sig = 3;
info->fix = 3;
nmea_igen_static_reset(gen, info);
return 1;
}
/*
* SAT_ROTATE generator
*/
int nmea_igen_rotate_loop(nmeaGENERATOR *gen, nmeaINFO *info)
{
int it;
int count = info->satinfo.inview;
double deg = 360 / (count?count:1);
double srt = (count?(info->satinfo.sat[0].azimuth):0) + 5;
nmea_time_now(&info->utc);
for(it = 0; it < count; ++it)
{
info->satinfo.sat[it].azimuth =
(int)((srt >= 360)?srt - 360:srt);
srt += deg;
}
return 1;
};
int nmea_igen_rotate_reset(nmeaGENERATOR *gen, nmeaINFO *info)
{
int it;
double deg = 360 / 8;
double srt = 0;
info->satinfo.inuse = 8;
info->satinfo.inview = 8;
for(it = 0; it < info->satinfo.inview; ++it)
{
info->satinfo.sat[it].id = it + 1;
info->satinfo.sat[it].in_use = 1;
info->satinfo.sat[it].elv = 5;
info->satinfo.sat[it].azimuth = (int)srt;
info->satinfo.sat[it].sig = 80;
srt += deg;
}
return 1;
}
int nmea_igen_rotate_init(nmeaGENERATOR *gen, nmeaINFO *info)
{
info->sig = 3;
info->fix = 3;
nmea_igen_rotate_reset(gen, info);
return 1;
}
/*
* POS_RANDMOVE generator
*/
int nmea_igen_pos_rmove_init(nmeaGENERATOR *gen, nmeaINFO *info)
{
info->sig = 3;
info->fix = 3;
info->direction = info->declination = 0;
info->speed = 20;
return 1;
}
int nmea_igen_pos_rmove_loop(nmeaGENERATOR *gen, nmeaINFO *info)
{
nmeaPOS crd;
info->direction += nmea_random(-10, 10);
info->speed += nmea_random(-2, 3);
if(info->direction < 0)
info->direction = 359 + info->direction;
if(info->direction > 359)
info->direction -= 359;
if(info->speed > 40)
info->speed = 40;
if(info->speed < 1)
info->speed = 1;
nmea_info2pos(info, &crd);
nmea_move_horz(&crd, &crd, info->direction, info->speed / 3600);
nmea_pos2info(&crd, info);
info->declination = info->direction;
return 1;
};
int nmea_igen_pos_rmove_destroy(nmeaGENERATOR *gen)
{
return 1;
};
/*
* generator create
*/
nmeaGENERATOR * __nmea_create_generator(int type, nmeaINFO *info)
{
nmeaGENERATOR *gen = 0;
switch(type)
{
case NMEA_GEN_NOISE:
if(0 == (gen = malloc(sizeof(nmeaGENERATOR))))
nmea_error("Insufficient memory!");
else
{
memset(gen, 0, sizeof(nmeaGENERATOR));
gen->init_call = &nmea_igen_noise_init;
gen->loop_call = &nmea_igen_noise_loop;
gen->reset_call = &nmea_igen_noise_reset;
}
break;
case NMEA_GEN_STATIC:
case NMEA_GEN_SAT_STATIC:
if(0 == (gen = malloc(sizeof(nmeaGENERATOR))))
nmea_error("Insufficient memory!");
else
{
memset(gen, 0, sizeof(nmeaGENERATOR));
gen->init_call = &nmea_igen_static_init;
gen->loop_call = &nmea_igen_static_loop;
gen->reset_call = &nmea_igen_static_reset;
}
break;
case NMEA_GEN_SAT_ROTATE:
if(0 == (gen = malloc(sizeof(nmeaGENERATOR))))
nmea_error("Insufficient memory!");
else
{
memset(gen, 0, sizeof(nmeaGENERATOR));
gen->init_call = &nmea_igen_rotate_init;
gen->loop_call = &nmea_igen_rotate_loop;
gen->reset_call = &nmea_igen_rotate_reset;
}
break;
case NMEA_GEN_POS_RANDMOVE:
if(0 == (gen = malloc(sizeof(nmeaGENERATOR))))
nmea_error("Insufficient memory!");
else
{
memset(gen, 0, sizeof(nmeaGENERATOR));
gen->init_call = &nmea_igen_pos_rmove_init;
gen->loop_call = &nmea_igen_pos_rmove_loop;
gen->destroy_call = &nmea_igen_pos_rmove_destroy;
}
break;
case NMEA_GEN_ROTATE:
gen = __nmea_create_generator(NMEA_GEN_SAT_ROTATE, info);
nmea_gen_add(gen, __nmea_create_generator(NMEA_GEN_POS_RANDMOVE, info));
break;
};
return gen;
}
nmeaGENERATOR * nmea_create_generator(int type, nmeaINFO *info)
{
nmeaGENERATOR *gen = __nmea_create_generator(type, info);
if(gen)
nmea_gen_init(gen, info);
return gen;
}
void nmea_destroy_generator(nmeaGENERATOR *gen)
{
nmea_gen_destroy(gen);
}
#if defined(NMEA_WIN) && defined(_MSC_VER)
# pragma warning(default: 4100)
#endif
This diff is collapsed.
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: info.c 17 2008-03-11 11:56:11Z xtimor $
*
*/
#include <string.h>
#include "nmea/info.h"
void nmea_zero_INFO(nmeaINFO *info)
{
memset(info, 0, sizeof(nmeaINFO));
nmea_time_now(&info->utc);
info->sig = NMEA_SIG_BAD;
info->fix = NMEA_FIX_BAD;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: sentence.c 17 2008-03-11 11:56:11Z xtimor $
*
*/
#include "nmea/sentence.h"
#include <string.h>
void nmea_zero_GPGGA(nmeaGPGGA *pack)
{
memset(pack, 0, sizeof(nmeaGPGGA));
nmea_time_now(&pack->utc);
pack->ns = 'N';
pack->ew = 'E';
pack->elv_units = 'M';
pack->diff_units = 'M';
}
void nmea_zero_GPGSA(nmeaGPGSA *pack)
{
memset(pack, 0, sizeof(nmeaGPGSA));
pack->fix_mode = 'A';
pack->fix_type = NMEA_FIX_BAD;
}
void nmea_zero_GPGSV(nmeaGPGSV *pack)
{
memset(pack, 0, sizeof(nmeaGPGSV));
}
void nmea_zero_GPRMC(nmeaGPRMC *pack)
{
memset(pack, 0, sizeof(nmeaGPRMC));
nmea_time_now(&pack->utc);
pack->status = 'V';
pack->ns = 'N';
pack->ew = 'E';
pack->declin_ew = 'E';
}
void nmea_zero_GPVTG(nmeaGPVTG *pack)
{
memset(pack, 0, sizeof(nmeaGPVTG));
pack->dir_t = 'T';
pack->dec_m = 'M';
pack->spn_n = 'N';
pack->spk_k = 'K';
}
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim (xtimor@gmail.com)
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: time.c 4 2007-08-27 13:11:03Z xtimor $
*
*/
/*! \file time.h */
#include "nmea/time.h"
#ifdef NMEA_WIN
# pragma warning(disable: 4201)
# pragma warning(disable: 4214)
# pragma warning(disable: 4115)
# include <windows.h>
# pragma warning(default: 4201)
# pragma warning(default: 4214)
# pragma warning(default: 4115)
#else
# include <time.h>
#endif
#ifdef NMEA_WIN
void nmea_time_now(nmeaTIME *stm)
{
SYSTEMTIME st;
GetSystemTime(&st);
stm->year = st.wYear - 1900;
stm->mon = st.wMonth - 1;
stm->day = st.wDay;
stm->hour = st.wHour;
stm->min = st.wMinute;
stm->sec = st.wSecond;
stm->hsec = st.wMilliseconds / 10;
}
#else /* NMEA_WIN */
void nmea_time_now(nmeaTIME *stm)
{
time_t lt;
struct tm *tt;
time(&lt);
tt = gmtime(&lt);
stm->year = tt->tm_year;
stm->mon = tt->tm_mon;
stm->day = tt->tm_mday;
stm->hour = tt->tm_hour;
stm->min = tt->tm_min;
stm->sec = tt->tm_sec;
stm->hsec = 0;
}
#endif
This diff is collapsed.
CC = gcc
CFLAGS = -Wall $(INCLUDE)
INCLUDE = -I../nmealib/include
OBJS = main.o
LIB = -lnmea
LIBDIR = -L../nmealib/lib
all: $(OBJS)
$(CC) $(CFLAGS) -o nmeatest $^ $(LIBDIR) $(LIB)
clean:
rm nmeatest $(OBJS)
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include "nmea/nmea.h"
int main()
{
char buf[256];
FILE *f;
int i = 0;
nmeaINFO info;
nmeaPARSER p;
nmea_zero_INFO(&info);
nmea_parser_init(&p);
f = fopen("/dev/ttyUSB0", "r");
while (1) {
while (!((buf[i-2] == '\r') && (buf[i-1] == '\n'))) {
fread(&buf[i++], 1, 1, f);
}
buf[i] = '\0';
i = 0;
nmea_parse(&p, buf, strlen(buf), &info);
printf("UTC : %d:%d:%d\n", info.utc.hour,
info.utc.min,
info.utc.sec);
printf("Latitude : %f\n", info.lat);
printf("Longitude: %f\n", info.lon);
printf("Elevation: %f\n", info.elv);
printf("Speed : %f\n", info.speed);
printf("Direction: %f\n", info.direction);
printf("\n");
}
fclose(f);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment