Paparazzi UAS  v5.12_stable-4-g9b43e9b
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
gps_nmea.c File Reference

Basic parser for the NMEA protocol. More...

#include "gps_nmea.h"
#include "subsystems/gps.h"
#include "subsystems/abi.h"
#include "led.h"
#include "math/pprz_geodetic_float.h"
#include <inttypes.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
+ Include dependency graph for gps_nmea.c:

Go to the source code of this file.

Macros

#define NMEA_PRINT(...)   {};
 
#define WAIT   0
 
#define GOT_START   1
 
#define GOT_CHECKSUM   2
 
#define GOT_END   3
 

Functions

static bool nmea_parse_GSA (void)
 Parse GSA NMEA messages. More...
 
static bool nmea_parse_RMC (void)
 Parse RMC NMEA messages. More...
 
static bool nmea_parse_GGA (void)
 Parse GGA NMEA messages. More...
 
static bool nmea_parse_GSV (void)
 Parse GSV-nmea-messages. More...
 
void gps_nmea_init (void)
 
void gps_nmea_event (void)
 
void nmea_gps_msg (void)
 
void WEAK nmea_configure (void)
 The function to be called when a characted from the device is available. More...
 
void WEAK nmea_parse_prop_init (void)
 
bool WEAK nmea_parse_prop_msg (void)
 
bool nmea_parse_msg (void)
 nmea_parse_char() has a complete line. More...
 
void nmea_parse_char (uint8_t c)
 This is the actual parser. More...
 
uint8_t nmea_calc_crc (const char *buff, int buff_sz)
 Calculate control sum of binary buffer. More...
 

Variables

struct GpsNmea gps_nmea
 

Detailed Description

Basic parser for the NMEA protocol.

Status: Parsing GGA, RMC, GSA and GSV.

Definition in file gps_nmea.c.

Macro Definition Documentation

#define GOT_CHECKSUM   2

Definition at line 56 of file gps_nmea.c.

Referenced by nmea_parse_char().

#define GOT_END   3

Definition at line 57 of file gps_nmea.c.

Referenced by nmea_parse_char().

#define GOT_START   1

Definition at line 55 of file gps_nmea.c.

Referenced by nmea_parse_char().

#define NMEA_PRINT (   ...)    {};
#define WAIT   0

Definition at line 54 of file gps_nmea.c.

Referenced by nmea_parse_char(), and nmea_parse_msg().

Function Documentation

void gps_nmea_event ( void  )

Definition at line 78 of file gps_nmea.c.

References dev, gps_nmea, GpsNmea::is_configured, GpsNmea::msg_available, nmea_configure(), nmea_gps_msg(), and nmea_parse_char().

+ Here is the call graph for this function:

void gps_nmea_init ( void  )
uint8_t nmea_calc_crc ( const char *  buff,
int  buff_sz 
)

Calculate control sum of binary buffer.

Definition at line 243 of file gps_nmea.c.

Referenced by nmea_configure().

+ Here is the caller graph for this function:

void WEAK nmea_configure ( void  )

The function to be called when a characted from the device is available.

The function to be called when a characted from the device is available.

Sets gps_nmea.is_configured to TRUE if all config msgs are sent.

Definition at line 113 of file gps_nmea.c.

References crc, fd, furuno_cfg_cnt, gps_furuno_settings, GPS_FURUNO_SETTINGS_NB, gps_nmea, GpsLinkDevice, GpsNmea::is_configured, and nmea_calc_crc().

Referenced by gps_nmea_event(), and gps_nmea_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void nmea_gps_msg ( void  )

Definition at line 95 of file gps_nmea.c.

References GpsState::fix, get_sys_time_usec(), GPS_FIX_3D, gps_nmea, GPS_NMEA_ID, GpsState::last_3dfix_ticks, GpsState::last_3dfix_time, GpsState::last_msg_ticks, GpsState::last_msg_time, sys_time::nb_sec, sys_time::nb_sec_rem, nmea_parse_msg(), and GpsNmea::state.

Referenced by gps_nmea_event().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void nmea_parse_char ( uint8_t  c)

This is the actual parser.

It reads one character at a time setting gps_nmea.msg_available to TRUE after a full line.

Definition at line 174 of file gps_nmea.c.

References GOT_CHECKSUM, GOT_END, GOT_START, gps_nmea, GpsNmea::msg_available, GpsNmea::msg_buf, GpsNmea::msg_len, NMEA_MAXLEN, NMEA_PRINT, GpsNmea::status, and WAIT.

Referenced by gps_nmea_event().

+ Here is the caller graph for this function:

static bool nmea_parse_GGA ( void  )
static

Parse GGA NMEA messages.

GGA has essential fix data providing 3D location and HDOP. Msg stored in gps_nmea.msg_buf.

Returns
true if msg was valid and gps_nmea.state updated

Definition at line 380 of file gps_nmea.c.

References LlaCoor_f::alt, LlaCoor_i::alt, ecef_of_lla_f(), GpsState::ecef_pos, gps_nmea, GPS_VALID_HMSL_BIT, GPS_VALID_POS_ECEF_BIT, GPS_VALID_POS_LLA_BIT, GpsState::hmsl, LlaCoor_f::lat, LlaCoor_i::lat, GpsState::lla_pos, LlaCoor_f::lon, LlaCoor_i::lon, GpsNmea::msg_buf, NMEA_PRINT, nmea_read_until(), GpsState::num_sv, GpsNmea::state, GpsState::tow, GpsState::valid_fields, EcefCoor_f::x, EcefCoor_i::x, EcefCoor_f::y, EcefCoor_i::y, EcefCoor_f::z, and EcefCoor_i::z.

Referenced by nmea_parse_msg().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool nmea_parse_GSA ( void  )
static

Parse GSA NMEA messages.

GPS DOP and active satellites. Msg stored in gps_nmea.msg_buf.

Returns
true if msg was valid and gps_nmea.state updated

Definition at line 261 of file gps_nmea.c.

References GpsState::fix, gps_nmea, GpsNmea::have_gsv, GpsNmea::msg_buf, NMEA_PRINT, nmea_read_until(), GpsState::pdop, GpsNmea::state, SVinfo::svid, and GpsState::svinfos.

Referenced by nmea_parse_msg().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool nmea_parse_GSV ( void  )
static

Parse GSV-nmea-messages.

Msg stored in gps_nmea.msg_buf.

Returns
true if msg was valid and gps_nmea.state updated

Definition at line 498 of file gps_nmea.c.

References SVinfo::azim, SVinfo::cno, SVinfo::elev, gps_nmea, GpsNmea::msg_buf, NMEA_PRINT, nmea_read_until(), GpsNmea::state, SVinfo::svid, and GpsState::svinfos.

Referenced by nmea_parse_msg().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool nmea_parse_msg ( void  )

nmea_parse_char() has a complete line.

Find out what type of message it is and hand it to the parser for that type.

Returns
true if msg was valid and gps_nmea.state updated

Definition at line 133 of file gps_nmea.c.

References gps_nmea, GpsNmea::have_gsv, GpsNmea::msg_buf, GpsNmea::msg_len, nmea_parse_GGA(), nmea_parse_GSA(), nmea_parse_GSV(), nmea_parse_prop_msg(), nmea_parse_RMC(), NMEA_PRINT, GpsNmea::status, and WAIT.

Referenced by nmea_gps_msg().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WEAK nmea_parse_prop_init ( void  )

Definition at line 118 of file gps_nmea.c.

References furuno_cfg_cnt.

Referenced by gps_nmea_init().

+ Here is the caller graph for this function:

bool WEAK nmea_parse_prop_msg ( void  )

Definition at line 122 of file gps_nmea.c.

References gps_nmea, GpsNmea::msg_buf, GpsNmea::msg_len, and nmea_parse_perdcrv().

Referenced by nmea_parse_msg().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool nmea_parse_RMC ( void  )
static

Parse RMC NMEA messages.

Recommended minimum GPS sentence. Msg stored in gps_nmea.msg_buf.

Returns
true if msg was valid and gps_nmea.state updated

Definition at line 330 of file gps_nmea.c.

References course, GpsState::course, gps_nmea, GPS_VALID_COURSE_BIT, GpsState::gspeed, GpsNmea::msg_buf, NMEA_PRINT, nmea_read_until(), GpsNmea::state, and GpsState::valid_fields.

Referenced by nmea_parse_msg().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation