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
NMEAUtils.c
00001 /** 00002 ******************************************************************************* 00003 * @file NMEA_utils.c 00004 * @author AST / Central Lab 00005 * @version V1.0.0 00006 * @date 18-May-2017 00007 * @brief NMEA utilities 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 #include "string.h" 00046 #include "NMEAUtils.h" 00047 00048 /** @defgroup Middlewares 00049 * @brief Contains all platform independent modules (eg. NMEA Sentence Parser, ...). 00050 * @{ 00051 */ 00052 00053 /** @defgroup ST 00054 * @{ 00055 */ 00056 00057 /** @defgroup LIB_NMEA 00058 * @{ 00059 */ 00060 00061 /** @defgroup NMEA_UTILS 00062 * @{ 00063 */ 00064 00065 /** @addtogroup NMEA_UTILS_PUBLIC_FUNCTIONS 00066 * @{ 00067 */ 00068 /** 00069 * @brief Scans a string with UTC info and fills all fields of a 00070 * UTC_Info struct 00071 * @param utc_str NMEA UTC string 00072 * @param utc The UTC_Info struct to fill 00073 * @retval None 00074 */ 00075 void scan_utc (char* utc_str, UTC_Info* utc) { 00076 00077 sscanf(utc_str, "%d", &utc->utc); 00078 00079 utc->hh = (utc->utc / 10000); 00080 utc->mm = (utc->utc - (utc->hh * 10000)) / 100; 00081 utc->ss = utc->utc - ((utc->hh * 10000) + (utc->mm * 100)); 00082 00083 return; 00084 } 00085 00086 /** 00087 * @brief Scans a bidimensional array with longitude and latitude infos and 00088 * fills the relative fields of a Coords struct 00089 * @param xy_str NMEA string with latitude and longitude infos 00090 * @param str_offset NMEA string with latitude and longitude infos 00091 * @param utc The Coords struct to fill 00092 * @retval None 00093 */ 00094 void scan_xy (char* xy_str, uint8_t str_offset, Coords* xy) 00095 { 00096 //printf("NMEA (xy_str): %s\n\r", xy_str); 00097 sscanf(xy_str, "%lf", &xy->lat); 00098 sscanf(xy_str+str_offset, "%c", &xy->ns); 00099 sscanf(xy_str+(2*str_offset), "%lf", &xy->lon); 00100 sscanf(xy_str+(3*str_offset), "%c", &xy->ew); 00101 00102 return; 00103 } 00104 00105 /** 00106 * @} 00107 */ 00108 00109 /** 00110 * @} 00111 */ 00112 00113 /** 00114 * @} 00115 */ 00116 00117 /** 00118 * @} 00119 */ 00120 00121 /** 00122 * @} 00123 */
Generated on Wed Jul 13 2022 01:04:53 by
