/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim ( [email protected])
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: units.h 4 2007-08-27 13:11:03Z xtimor $
*
*/
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim ( [email protected])
* 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__
#define __NMEA_UNITS_H__
#include "config.h"
/*
* Distance units
*/
* 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 */
#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
*/
* Speed units
*/
#define NMEA_TUS_MS (3.6) /**< Meters per seconds, (k/h) / NMEA_TUS_MS= (m/s) */
#endif /* __NMEA_UNITS_H__ */
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim ( [email protected])
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: context.h 4 2007-08-27 13:11:03Z xtimor $
*
*/
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim ( [email protected])
* 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__
#define __NMEA_CONTEXT_H__
#include "config.h"
#define NMEA_DEF_PARSEBUFF (1024)
//缺省的解析buf
#define NMEA_MIN_PARSEBUFF (256) //最小的解析buf
#define NMEA_MIN_PARSEBUFF (256) //最小的解析buf
#ifdef __cplusplus
extern "C" {
#endif
extern "C" {
#endif
typedef void (*nmeaTraceFunc)(const char *str, int str_size);
//一般typedef相当于define,但是这里是另一个用法:typedef 在编译时被解释,因此让编译器来应付超越预处理器能力的文本替换,http://baike.baidu.com/view/1283800.htm
typedef void (*nmeaErrorFunc)(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;
{
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); //跟踪确定大小的buf
void nmea_error(const char *str, ...);
void nmea_trace_buff(const char *buff, int buff_size); //跟踪确定大小的buf
void nmea_error(const char *str, ...);
#ifdef __cplusplus
}
#endif
}
#endif
#endif /* __NMEA_CONTEXT_H__ */
/*
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim ( [email protected])
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: context.c 17 2008-03-11 11:56:11Z xtimor $
*
*/
*
* NMEA library
* URL: http://nmea.sourceforge.net
* Author: Tim ( [email protected])
* Licence: http://www.gnu.org/licenses/lgpl.html
* $Id: context.c 17 2008-03-11 11:56:11Z xtimor $
*
*/
#include "nmea/context.h"
//标识具体路径的调用
#include
#include
#include
#include
#include
nmeaPROPERTY * nmea_property()
{
static nmeaPROPERTY prop = {
0, 0, NMEA_DEF_PARSEBUFF
}; //静态的初始值
{
static nmeaPROPERTY prop = {
0, 0, NMEA_DEF_PARSEBUFF
}; //静态的初始值
return ∝
}
}
void nmea_trace(const char *str, ...)
{
int size;
va_list arg_list;
char buff[NMEA_DEF_PARSEBUFF];
nmeaTraceFunc func = nmea_property()->trace_func; //一开始这里是0,那么什么时候会有值呢?
{
int size;
va_list arg_list;
char buff[NMEA_DEF_PARSEBUFF];
nmeaTraceFunc func = nmea_property()->trace_func; //一开始这里是0,那么什么时候会有值呢?
if(func)
{
va_start(arg_list, str);
size = NMEA_POSIX(vsnprintf)(&buff[0], NMEA_DEF_PARSEBUFF - 1, str, arg_list);
va_end(arg_list);
{
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); //!!!!!这个函数在哪里实现??
}
}
(*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);
}
{
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;
{
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);
{
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);
}
}
//奇怪!!!问题!!!两个重要的函数不知怎么实现? 暂时未解!!!
(*func)(&buff[0], size);
}
}
//奇怪!!!问题!!!两个重要的函数不知怎么实现? 暂时未解!!!