BeRTOS
|
00001 /* 00002 Copyright (c) 2005, David M Howard (daveh at dmh2000.com) 00003 All rights reserved. 00004 00005 This product is licensed for use and distribution under the BSD Open Source License. 00006 see the file COPYING for more details. 00007 00008 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00009 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00010 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00011 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00012 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 00013 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00014 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00015 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00016 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 00017 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00018 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00019 00020 */ 00021 00022 #ifndef __NMEAP_H__ 00023 #define __NMEAP_H__ 00024 00025 #ifdef __cplusplus 00026 extern "C" { 00027 #endif 00028 00029 #include "cfg/cfg_nmea.h" 00030 00031 /* 00032 ============================================ 00033 COMPILE TIME CONFIGURATION CONSTANTS 00034 ============================================ 00035 */ 00036 00037 /* these constants affect the size of the context object. tweak them as desired but know what you are doing */ 00038 00040 #define NMEAP_MAX_SENTENCES CONFIG_NMEAP_MAX_SENTENCES 00041 00042 #define NMEAP_MAX_SENTENCE_NAME_LENGTH 5 00043 00045 #define NMEAP_MAX_SENTENCE_LENGTH CONFIG_NMEAP_MAX_SENTENCE_LENGTH 00046 00047 #define NMEAP_MAX_TOKENS CONFIG_NMEAP_MAX_TOKENS 00048 00049 /* predefined message ID's */ 00050 00051 /* GGA MESSAGE ID */ 00052 #define NMEAP_GPGGA 1 00053 /* RMC MESSAGE ID */ 00054 #define NMEAP_GPRMC 2 00055 00057 #define NMEAP_USER 100 00058 00059 /* forward references */ 00060 struct nmeap_context; 00061 struct nmeap_sentence; 00062 00063 /* 00064 ============================================ 00065 CALLOUTS 00066 ============================================ 00067 */ 00068 00077 typedef void (*nmeap_callout_t)(struct nmeap_context *context,void *sentence_data,void *user_data); 00078 00089 typedef int (*nmeap_sentence_parser_t)(struct nmeap_context *context,struct nmeap_sentence *sentence); 00090 00091 00092 /* ==== opaque types === */ 00093 #include "nmeap_def.h" 00094 00095 00096 /* 00097 ============================================ 00098 STANDARD SENTENCE DATA STRUCTURES 00099 ============================================ 00100 */ 00101 00103 struct nmeap_gga { 00104 double latitude; 00105 double longitude; 00106 double altitude; 00107 unsigned long time; 00108 int satellites; 00109 int quality; 00110 double hdop; 00111 double geoid; 00112 }; 00113 typedef struct nmeap_gga nmeap_gga_t; 00114 00116 struct nmeap_rmc { 00117 unsigned long time; 00118 char warn; 00119 double latitude; 00120 double longitude; 00121 double speed; 00122 double course; 00123 unsigned long date; 00124 double magvar; 00125 }; 00126 00127 typedef struct nmeap_rmc nmeap_rmc_t; 00128 00129 /* 00130 ============================================ 00131 METHODS 00132 ============================================ 00133 */ 00134 00141 int nmeap_init(nmeap_context_t *context,void *user_data); 00142 00155 int nmeap_addParser(nmeap_context_t *context, 00156 const char *sentence_name, 00157 nmeap_sentence_parser_t sentence_parser, 00158 nmeap_callout_t sentence_callout, 00159 void *sentence_data 00160 ); 00161 00170 int nmeap_parseBuffer(nmeap_context_t *context,const char *buffer,int *length); 00171 00178 int nmeap_parse(nmeap_context_t *context,char ch); 00179 00180 00186 int nmeap_gpgga(nmeap_context_t *context,nmeap_sentence_t *sentence); 00187 00193 int nmeap_gprmc(nmeap_context_t *context,nmeap_sentence_t *sentence); 00194 00201 double nmeap_latitude(const char *plat,const char *phem); 00202 00203 00210 double nmeap_longitude(const char *plat,const char *phem); 00211 00212 00219 double nmeap_altitude(const char *palt,const char *punits); 00220 00221 #ifdef __cplusplus 00222 } // extern C 00223 #endif 00224 00225 00226 #endif 00227