Guido Ottaviani / Mbed 2 deprecated LeonardoMbos

Dependencies:   mbos Watchdog TextLCD mbed ConfigFile

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers context.c Source File

context.c

00001 /*
00002  *
00003  * NMEA library
00004  * URL: http://nmea.sourceforge.net
00005  * Author: Tim (xtimor@gmail.com)
00006  * Licence: http://www.gnu.org/licenses/lgpl.html
00007  * $Id: context.c 17 2008-03-11 11:56:11Z xtimor $
00008  *
00009  */
00010 
00011 #include "nmea/context.h"
00012 
00013 #include <string.h>
00014 #include <stdarg.h>
00015 #include <stdio.h>
00016 
00017 nmeaPROPERTY * nmea_property()
00018 {
00019     static nmeaPROPERTY prop = {
00020         0, 0, NMEA_DEF_PARSEBUFF
00021         };
00022 
00023     return &prop;
00024 }
00025 
00026 void nmea_trace(const char *str, ...)
00027 {
00028     int size;
00029     va_list arg_list;
00030     char buff[NMEA_DEF_PARSEBUFF];
00031     nmeaTraceFunc func = nmea_property()->trace_func;
00032 
00033     if(func)
00034     {
00035         va_start(arg_list, str);
00036         size = NMEA_POSIX(vsnprintf)(&buff[0], NMEA_DEF_PARSEBUFF - 1, str, arg_list);
00037         va_end(arg_list);
00038 
00039         if(size > 0)
00040             (*func)(&buff[0], size);
00041     }
00042 }
00043 
00044 void nmea_trace_buff(const char *buff, int buff_size)
00045 {
00046     nmeaTraceFunc func = nmea_property()->trace_func;
00047     if(func && buff_size)
00048         (*func)(buff, buff_size);
00049 }
00050 
00051 void nmea_error(const char *str, ...)
00052 {
00053     int size;
00054     va_list arg_list;
00055     char buff[NMEA_DEF_PARSEBUFF];
00056     nmeaErrorFunc func = nmea_property()->error_func;
00057 
00058     if(func)
00059     {
00060         va_start(arg_list, str);
00061         size = NMEA_POSIX(vsnprintf)(&buff[0], NMEA_DEF_PARSEBUFF - 1, str, arg_list);
00062         va_end(arg_list);
00063 
00064         if(size > 0)
00065             (*func)(&buff[0], size);
00066     }
00067 }