77 (C)2013 Semtech-Cycleo
88
99Description:
10- Library of functions to manage a GNSS module (typically GPS) for accurate
11- timestamping of packets and synchronisation of gateways.
12- A limited set of module brands/models are supported.
10+ Library of functions to manage a GNSS module (typically GPS) for accurate
11+ timestamping of packets and synchronisation of gateways.
12+ A limited set of module brands/models are supported.
1313
1414License: Revised BSD License, see LICENSE.TXT file include in the project
1515Maintainer: Sylvain Miermont
@@ -23,17 +23,12 @@ Maintainer: Sylvain Miermont
2323/* --- DEPENDANCIES --------------------------------------------------------- */
2424
2525/* fix an issue between POSIX and C99 */
26- #if __STDC_VERSION__ >= 199901L
27- #define _XOPEN_SOURCE 600
28- #else
29- #define _XOPEN_SOURCE 500
30- #endif
31-
32- #include <stdint.h> /* C99 types */
33- #include <time.h> /* time library */
34- #include <termios.h> /* speed_t */
26+ #define _GNU_SOURCE
27+ #include <stdint.h> /* C99 types */
28+ #include <time.h> /* time library */
29+ #include <termios.h> /* speed_t */
3530
36- #include "config.h" /* library configuration options (dynamically generated) */
31+ #include "config.h" /* library configuration options (dynamically generated) */
3732
3833/* -------------------------------------------------------------------------- */
3934/* --- PUBLIC TYPES --------------------------------------------------------- */
@@ -43,54 +38,54 @@ Maintainer: Sylvain Miermont
4338@brief Time solution required for timestamp to absolute time conversion
4439*/
4540struct tref {
46- time_t systime ; /*!> system time when solution was calculated */
47- uint32_t count_us ; /*!> reference concentrator internal timestamp */
48- struct timespec utc ; /*!> reference UTC time (from GPS) */
49- double xtal_err ; /*!> raw clock error (eg. <1 'slow' XTAL) */
41+ time_t systime ; /*!> system time when solution was calculated */
42+ uint32_t count_us ; /*!> reference concentrator internal timestamp */
43+ struct timespec utc ; /*!> reference UTC time (from GPS) */
44+ double xtal_err ; /*!> raw clock error (eg. <1 'slow' XTAL) */
5045};
5146
5247/**
5348@struct coord_s
5449@brief Geodesic coordinates
5550*/
5651struct coord_s {
57- double lat ; /*!> latitude [-90,90] (North +, South -) */
58- double lon ; /*!> longitude [-180,180] (East +, West -)*/
59- short alt ; /*!> altitude in meters (WGS 84 geoid ref.) */
52+ double lat ; /*!> latitude [-90,90] (North +, South -) */
53+ double lon ; /*!> longitude [-180,180] (East +, West -)*/
54+ short alt ; /*!> altitude in meters (WGS 84 geoid ref.) */
6055};
6156
6257/**
6358@enum gps_msg
6459@brief Type of GPS (and other GNSS) sentences
6560*/
6661enum gps_msg {
67- UNKNOWN , /*!> neutral value */
68- IGNORED , /*!> frame was not parsed by the system */
69- INVALID , /*!> system try to parse frame but failed */
70- /* NMEA messages of interest */
71- NMEA_RMC , /*!> Recommended Minimum data (time + date) */
72- NMEA_GGA , /*!> Global positioning system fix data (pos + alt) */
73- NMEA_GNS , /*!> GNSS fix data (pos + alt, sat number) */
74- NMEA_ZDA , /*!> Time and Date */
75- /* NMEA message useful for time reference quality assessment */
76- NMEA_GBS , /*!> GNSS Satellite Fault Detection */
77- NMEA_GST , /*!> GNSS Pseudo Range Error Statistics */
78- NMEA_GSA , /*!> GNSS DOP and Active Satellites (sat number) */
79- NMEA_GSV , /*!> GNSS Satellites in View (sat SNR) */
80- /* Misc. NMEA messages */
81- NMEA_GLL , /*!> Latitude and longitude, with time fix and status */
82- NMEA_TXT , /*!> Text Transmission */
83- NMEA_VTG , /*!> Course over ground and Ground speed */
84- /* uBlox proprietary NMEA messages of interest */
85- UBX_POSITION , /*!> */
86- UBX_TIME /*!> */
62+ UNKNOWN , /*!> neutral value */
63+ IGNORED , /*!> frame was not parsed by the system */
64+ INVALID , /*!> system try to parse frame but failed */
65+ /* NMEA messages of interest */
66+ NMEA_RMC , /*!> Recommended Minimum data (time + date) */
67+ NMEA_GGA , /*!> Global positioning system fix data (pos + alt) */
68+ NMEA_GNS , /*!> GNSS fix data (pos + alt, sat number) */
69+ NMEA_ZDA , /*!> Time and Date */
70+ /* NMEA message useful for time reference quality assessment */
71+ NMEA_GBS , /*!> GNSS Satellite Fault Detection */
72+ NMEA_GST , /*!> GNSS Pseudo Range Error Statistics */
73+ NMEA_GSA , /*!> GNSS DOP and Active Satellites (sat number) */
74+ NMEA_GSV , /*!> GNSS Satellites in View (sat SNR) */
75+ /* Misc. NMEA messages */
76+ NMEA_GLL , /*!> Latitude and longitude, with time fix and status */
77+ NMEA_TXT , /*!> Text Transmission */
78+ NMEA_VTG , /*!> Course over ground and Ground speed */
79+ /* uBlox proprietary NMEA messages of interest */
80+ UBX_POSITION , /*!> */
81+ UBX_TIME /*!> */
8782};
8883
8984/* -------------------------------------------------------------------------- */
9085/* --- PUBLIC CONSTANTS ----------------------------------------------------- */
9186
92- #define LGW_GPS_SUCCESS 0
93- #define LGW_GPS_ERROR -1
87+ #define LGW_GPS_SUCCESS 0
88+ #define LGW_GPS_ERROR -1
9489
9590/* -------------------------------------------------------------------------- */
9691/* --- PUBLIC FUNCTIONS PROTOTYPES ------------------------------------------ */
@@ -113,9 +108,9 @@ int lgw_gps_enable(char* tty_path, char* gps_familly, speed_t target_brate, int*
113108@param buff_size maximum string lengths for NMEA parsing (incl. null char)
114109@return type of frame parsed
115110
116- The RAW NMEA sentences are parsed to a global set of variables shared with the
111+ The RAW NMEA sentences are parsed to a global set of variables shared with the
117112lgw_gps_get function.
118- If the lgw_parse_nmea and lgw_gps_get are used in different threads, a mutex
113+ If the lgw_parse_nmea and lgw_gps_get are used in different threads, a mutex
119114lock must be acquired before calling either function.
120115*/
121116enum gps_msg lgw_parse_nmea (char * serial_buff , int buff_size );
@@ -128,10 +123,10 @@ enum gps_msg lgw_parse_nmea(char* serial_buff, int buff_size);
128123@param err pointer to store coordinates standard deviation (NULL to ignore)
129124@return success if the chosen elements could be returned
130125
131- This function read the global variables generated by the NMEA parsing function
132- lgw_parse_nmea. It returns time and location data in a format that is
126+ This function read the global variables generated by the NMEA parsing function
127+ lgw_parse_nmea. It returns time and location data in a format that is
133128exploitable by other functions in that library sub-module.
134- If the lgw_parse_nmea and lgw_gps_get are used in different threads, a mutex
129+ If the lgw_parse_nmea and lgw_gps_get are used in different threads, a mutex
135130lock must be acquired before calling either function.
136131*/
137132int lgw_gps_get (struct timespec * utc , struct coord_s * loc , struct coord_s * err );
@@ -156,8 +151,8 @@ int lgw_gps_sync(struct tref* ref, uint32_t count_us, struct timespec utc);
156151@param utc pointer to store UTC time, with ns precision (leap seconds ignored)
157152@return success if the function was able to convert timestamp to UTC
158153
159- This function is typically used when a packet is received to transform the
160- internal counter-based timestamp in an absolute timestamp with an accuracy in
154+ This function is typically used when a packet is received to transform the
155+ internal counter-based timestamp in an absolute timestamp with an accuracy in
161156the order of a couple microseconds (ns resolution).
162157*/
163158int lgw_cnt2utc (struct tref ref , uint32_t count_us , struct timespec * utc );
@@ -170,8 +165,8 @@ int lgw_cnt2utc(struct tref ref, uint32_t count_us, struct timespec* utc);
170165@param count_us pointer to store internal timestamp counter of LoRa concentrator
171166@return success if the function was able to convert UTC to timestamp
172167
173- This function is typically used when a packet must be sent at an accurate time
174- (eg. to send a piggy-back response after receiving a packet from a node) to
168+ This function is typically used when a packet must be sent at an accurate time
169+ (eg. to send a piggy-back response after receiving a packet from a node) to
175170transform an absolute UTC time into a matching internal concentrator timestamp.
176171*/
177172int lgw_utc2cnt (struct tref ref ,struct timespec utc , uint32_t * count_us );
0 commit comments