Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: A_TeseoLocationNEW A_TeseoLocation
NMEAParser.h
00001 /** 00002 ******************************************************************************* 00003 * @file NMEAParser.h 00004 * @author AST / Central Lab 00005 * @version V1.0.0 00006 * @date 18-May-2017 00007 * @brief NMEA sentence parser 00008 * 00009 ******************************************************************************* 00010 * @attention 00011 * 00012 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> 00013 * 00014 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 00015 * You may not use this file except in compliance with the License. 00016 * You may obtain a copy of the License at: 00017 * 00018 * http://www.st.com/software_license_agreement_liberty_v2 00019 * 00020 * Redistribution and use in source and binary forms, with or without modification, 00021 * are permitted provided that the following conditions are met: 00022 * 1. Redistributions of source code must retain the above copyright notice, 00023 * this list of conditions and the following disclaimer. 00024 * 2. Redistributions in binary form must reproduce the above copyright notice, 00025 * this list of conditions and the following disclaimer in the documentation 00026 * and/or other materials provided with the distribution. 00027 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00028 * may be used to endorse or promote products derived from this software 00029 * without specific prior written permission. 00030 * 00031 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00032 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00033 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00034 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00035 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00036 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00037 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00038 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00039 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00040 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00041 * 00042 ******************************************************************************** 00043 */ 00044 00045 /* Define to prevent recursive inclusion -------------------------------------*/ 00046 #ifndef __NMEA_PARSER_H 00047 #define __NMEA_PARSER_H 00048 00049 #ifdef __cplusplus 00050 extern "C" { 00051 #endif 00052 00053 #include <stdio.h> 00054 #include <stdint.h> 00055 00056 /** @defgroup Middlewares 00057 * @brief Contains all platform independent modules (eg. NMEA Sentence Parser, ...). 00058 * @{ 00059 */ 00060 00061 /** @defgroup ST 00062 * @{ 00063 */ 00064 00065 /** @defgroup LIB_NMEA 00066 * @{ 00067 */ 00068 00069 /** @defgroup NMEA_PARSER 00070 * @{ 00071 */ 00072 00073 /** @addtogroup NMEA_PARSER_CONSTANTS_DEFINITIONS 00074 * @{ 00075 */ 00076 /** 00077 * @brief Constant that indicates the maximum lenght of an NMEA sentence 00078 */ 00079 #define MAX_NMEA_SENTENCE_LEN 80 00080 00081 /** 00082 * @brief Constant that indicates the maximum number of satellites. 00083 */ 00084 #define MAX_SAT_NUM 12 00085 00086 /** 00087 * @brief Constant that indicates the maximum lenght of a string. 00088 */ 00089 #define MAX_STR_LEN 32 00090 00091 /** 00092 * @brief Constant that indicates the maximum lenght of NMEA message field. 00093 */ 00094 #define MAX_MSG_LEN 32//19 00095 /** 00096 * @} 00097 */ 00098 00099 #define MAX_GEOFENCES_NUM 8 00100 00101 /** @addtogroup NMEA_PARSER_TYPES_DEFINITIONS 00102 * @{ 00103 */ 00104 /** 00105 * @brief Enumeration structure that containes the types of feature messages 00106 */ 00107 typedef enum { 00108 GNSS_FEATURE_EN_MSG = 0, 00109 GNSS_GEOFENCE_CFG_MSG, 00110 GNSS_GEOFENCE_STATUS_MSG, 00111 GNSS_GEOFENCE_ALARM_MSG, 00112 GNSS_ODO_START_MSG, 00113 GNSS_ODO_STOP_MSG, 00114 GNSS_DATALOG_CFG_MSG, 00115 GNSS_DATALOG_START_MSG, 00116 GNSS_DATALOG_STOP_MSG, 00117 GNSS_DATALOG_ERASE_MSG 00118 } ParseFeatureMsg_Typedef; 00119 00120 /** 00121 * @brief Enumeration structure that containes the two success states of a parsing process 00122 */ 00123 typedef enum { 00124 PARSE_SUCC = 0, /**< Success status */ 00125 PARSE_FAIL = 1 /**< Fail status */ 00126 } ParseStatus_Typedef; 00127 00128 /** 00129 * @brief Enumeration structure that containes the tipologies of Gps fixing process got from a NMEA string 00130 */ 00131 typedef enum { 00132 INVALID = 0, /**< Invalid Fix status */ 00133 VALID = 1, /**< Valid Fix status */ 00134 DGPS_FIX = 2, /**< DGPS Fix status */ 00135 PPS_FIX = 3, /**< PPS Fix status */ 00136 REAL_TIME = 4, /**< Real Time Fix status */ 00137 FLOAT_REAL_TIME = 5, /**< Float Real Time Fix status */ 00138 ESTIMATED = 6, /**< Estimated Fix status */ 00139 MANUAL_MODE = 7, /**< Manual Mode Fix status */ 00140 SIMULATION_MODE = 8 /**< Simulation Mode Fix status */ 00141 } GPS_ValidTypedef; 00142 00143 /** 00144 * @brief Data structure that contains the coordinates informations 00145 */ 00146 typedef struct Coords { 00147 double lat; /**< Latitude */ 00148 double lon; /**< Longitude */ 00149 float alt; /**< Altitude */ 00150 uint8_t ns; /**< Nord / Sud latitude type */ 00151 uint8_t ew; /**< East / West longitude type */ 00152 uint8_t mis; /**< Altitude unit misure */ 00153 } Coords; 00154 00155 /** 00156 * @brief Data structure that contains the Gps geoids informations 00157 */ 00158 typedef struct Geoid_Info { 00159 int height; /**< Geoid height */ 00160 uint8_t mis; /**< Geoid height misure unit */ 00161 } Geoid_Info; 00162 00163 /** 00164 * @brief Data structure that contains the UTC informations 00165 */ 00166 typedef struct UTC_Info { 00167 int utc; /**< UTC Info */ 00168 int hh; /**< Hours */ 00169 int mm; /**< Minutes */ 00170 int ss; /**< Seconds */ 00171 } UTC_Info; 00172 00173 /** 00174 * @brief Data structure that contains the UTC informations 00175 */ 00176 typedef struct GSV_SAT_Info { 00177 int prn; /**< PRN */ 00178 int elev; /**< Elevation of satellite in degree, 0 ... 90 */ 00179 int azim; /**< Azimuth of satellite in degree, ref. "North, " 0 ... 359 */ 00180 int cn0; /**< Carrier to noise ratio for satellite in dB, 0 ... 99 */ 00181 } GSV_SAT_Info; 00182 00183 /** 00184 * @brief Data structure that contains all of the informations about the GPS position 00185 */ 00186 typedef struct GPGGA_Infos { 00187 UTC_Info utc; /**< UTC Time */ 00188 Coords xyz; /**< Coords data member */ 00189 float acc; /**< GPS Accuracy */ 00190 int sats; /**< Number of satellities acquired */ 00191 GPS_ValidTypedef valid; /**< GPS Signal fix quality */ 00192 Geoid_Info geoid; /**< Geoids data info member */ 00193 int update; /**< Update time from the last acquired GPS Info */ 00194 int checksum; /**< Checksum of the message bytes */ 00195 } GPGGA_Infos; 00196 00197 /** 00198 * @brief Data structure that contains all of the informations about the fix data for single or 00199 * combined satellite navigation system. 00200 */ 00201 typedef struct GNS_Infos { 00202 char constellation[MAX_STR_LEN]; /**< Constellation enabled: GPGNS (GPS), GLGNS (GLONASS), GAGNS (GALILEO), BDGNS (BEIDOU), QZGNS (QZSS), GNGNS (more than one) */ 00203 UTC_Info utc; /**< UTC Time */ 00204 Coords xyz; /**< Coords data member */ 00205 char gps_mode; /**< N = NO Fix, A = Autonomous, D = Differential GPS, E = Estimated (dead reckoning mode) */ 00206 char glonass_mode; /**< N = NO Fix, A = Autonomous, D = Differential Glonass, E = Estimated (dead reckoning mode) */ 00207 int sats; /**< Number of satellities acquired */ 00208 float hdop; /**< Horizontal Dilution of Precision, max: 99.0 */ 00209 float geo_sep; /**< Geoidal separation, meter */ 00210 char dgnss_age; /**< Not supported */ 00211 char dgnss_ref; /**< Not supported */ 00212 int checksum; /**< Checksum of the message bytes */ 00213 } GNS_Infos; 00214 00215 /** 00216 * @brief Data structure that contains all of the GPS Pseudorange Noise Statistics. 00217 */ 00218 typedef struct GPGST_Infos { 00219 UTC_Info utc; /**< UTC Time */ 00220 float EHPE; /**< Equivalent Horizontal Position Error */ 00221 float semi_major_dev; /**< Standard deviation (meters) of semi-major axis of error ellipse */ 00222 float semi_minor_dev; /**< Standard deviation (meters) of semi-minor axis of error ellipse */ 00223 float semi_major_angle; /**< Orientation of semi-major axis of error ellipse (true north degrees) */ 00224 float lat_err_dev; /**< Standard deviation (meters) of latitude error */ 00225 float lon_err_dev; /**< Standard deviation (meters) of longitude error */ 00226 float alt_err_dev; /**< Standard deviation (meters) of altitude error */ 00227 int checksum; /**< Checksum of the message bytes */ 00228 } GPGST_Infos; 00229 00230 /** 00231 * @brief Data structure that contains all the Recommended Minimum Specific GPS/Transit data. 00232 */ 00233 typedef struct GPRMC_Infos { 00234 UTC_Info utc; /**< UTC Time */ 00235 char status; /**< “A” = valid, “V” = Warning */ 00236 Coords xyz; /**< Coords data member */ 00237 float speed; /**< Speed over ground in knots */ 00238 float trackgood; /**< Course made good */ 00239 int date; /**< Date of Fix */ 00240 float mag_var; /**< Magnetic Variation */ 00241 char mag_var_dir; /**< Magnetic Variation Direction */ 00242 int checksum; /**< Checksum of the message bytes */ 00243 } GPRMC_Infos; 00244 00245 /** 00246 * @brief Data structure that contains all of the informations about the GSA satellites 00247 */ 00248 typedef struct GSA_Infos { 00249 char constellation[MAX_STR_LEN]; /**< Constellation enabled: GPGSA (GPS), GLGSA (GLONASS), GAGSA (GALILEO), BDGSA (BEIDOU), GNGSA (more than one) */ 00250 char operating_mode; /**< Operating Mode: 'M' = Manual, 'A' = Auto (2D/3D) */ 00251 int current_mode; /**< Current Mode: 1. no fix available, 2. 2D, 3. 3D */ 00252 int sat_prn[MAX_SAT_NUM]; /**< Satellites list used in position fix (max N 12) */ 00253 float pdop; /**< Position Dilution of Precision, max: 99.0 */ 00254 float hdop; /**< Horizontal Dilution of Precision, max: 99.0 */ 00255 float vdop; /**< Vertical Dilution of Precision, max: 99.0 */ 00256 int checksum; /**< Checksum of the message bytes */ 00257 } GSA_Infos; 00258 00259 /** 00260 * @brief Data structure that contains all of the informations about the GSV satellites 00261 */ 00262 typedef struct GSV_Infos { 00263 char constellation[MAX_STR_LEN]; /**< Constellation enabled: GPGSV (GPS), GLGSV (GLONASS), GAGSV (GALILEO), BDGSV (BEIDOU), QZGSV (QZSS), GNGSV (more than one) */ 00264 int amount; /**< Total amount of GSV messages, max. 3 */ 00265 int number; /**< Continued GSV number of this message */ 00266 int tot_sats; /**< Total Number of Satellites in view, max. 12 */ 00267 GSV_SAT_Info gsv_sat_i[MAX_SAT_NUM]; /**< Satellite info */ 00268 int checksum; /**< Checksum of the message bytes */ 00269 } GSV_Infos; 00270 00271 /** 00272 * @brief Data structure that contains timestamp 00273 */ 00274 typedef struct Timestamp_Info { 00275 int hh; /**< Hours */ 00276 int mm; /**< Minutes */ 00277 int ss; /**< Seconds */ 00278 int year; /**< Year */ 00279 int month; /**< Month */ 00280 int day; /**< Day */ 00281 } Timestamp_Info; 00282 00283 /** 00284 * @brief Data structure that contains all of the information about Geofence 00285 */ 00286 typedef struct Geofence_Infos { 00287 uint8_t op; /**< Geofence type message (configuration/status) */ 00288 uint8_t result; /**< Geofence cfg/request result (OK/ERROR) */ 00289 int idAlarm; /**< Id of the circle raising the alarm */ 00290 Timestamp_Info timestamp; 00291 int status[MAX_GEOFENCES_NUM]; 00292 } Geofence_Infos; 00293 00294 /** 00295 * @brief Data structure that contains all of the information about Ododmeter 00296 */ 00297 typedef struct Odometer_Infos { 00298 uint8_t op; /**< Odometer type message (configuration/status) */ 00299 uint8_t result; /**< Odometer cfg/request result (OK/ERROR) */ 00300 } Odometer_Infos; 00301 00302 /** 00303 * @brief Data structure that contains all of the information about Datalog 00304 */ 00305 typedef struct Datalog_Infos { 00306 uint8_t op; /**< Datalog type message (configuration/status) */ 00307 uint8_t result; /**< Datalog cfg/request result (OK/ERROR) */ 00308 } Datalog_Infos; 00309 00310 /** 00311 * @brief Ack from Teseo 00312 */ 00313 typedef uint8_t Ack_Info; 00314 00315 /** 00316 * @} 00317 */ 00318 00319 /** @addtogroup NMEA_PARSER_PUBLIC_FUNCTIONS 00320 * @{ 00321 */ 00322 ParseStatus_Typedef parse_gpgga (GPGGA_Infos *gpgga_data, uint8_t *NMEA); 00323 ParseStatus_Typedef parse_gnsmsg (GNS_Infos *gns_data, uint8_t *NMEA); 00324 ParseStatus_Typedef parse_gpgst (GPGST_Infos *gpgst_data, uint8_t *NMEA); 00325 ParseStatus_Typedef parse_gprmc (GPRMC_Infos *gprmc_data, uint8_t *NMEA); 00326 ParseStatus_Typedef parse_gsamsg (GSA_Infos *gsa_data, uint8_t *NMEA); 00327 ParseStatus_Typedef parse_gsvmsg (GSV_Infos *gsv_data, uint8_t *NMEA); 00328 void copy_data (GPGGA_Infos *, GPGGA_Infos); 00329 00330 ParseStatus_Typedef parse_pstmgeofence (Geofence_Infos *geofence_data, uint8_t *NMEA); 00331 ParseStatus_Typedef parse_pstmodo (Odometer_Infos *odo_data, uint8_t *NMEA); 00332 ParseStatus_Typedef parse_pstmdatalog (Datalog_Infos *datalog_data, uint8_t *NMEA); 00333 ParseStatus_Typedef parse_pstmsgl (Ack_Info *ack, uint8_t *NMEA); 00334 ParseStatus_Typedef parse_pstmsavepar (Ack_Info *ack, uint8_t *NMEA); 00335 /** 00336 * @} 00337 */ 00338 00339 /** 00340 * @} 00341 */ 00342 00343 /** 00344 * @} 00345 */ 00346 00347 /** 00348 * @} 00349 */ 00350 00351 /** 00352 * @} 00353 */ 00354 00355 #ifdef __cplusplus 00356 } 00357 #endif 00358 00359 #endif
Generated on Wed Jul 13 2022 01:04:53 by
