Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
gps_nmea.c File Reference

Basic parser for the NMEA protocol. More...

#include "gps_nmea.h"
#include "modules/gps/gps.h"
#include "modules/core/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.
static bool nmea_parse_RMC (void)
 Parse RMC NMEA messages.
static bool nmea_parse_GGA (void)
 Parse GGA NMEA messages.
static bool nmea_parse_GSV (void)
 Parse GSV-nmea-messages.
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.
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.
void nmea_parse_char (uint8_t c)
 This is the actual parser.
uint8_t nmea_calc_crc (const char *buff, int buff_sz)
 Calculate control sum of binary buffer.

Variables

struct GpsNmea gps_nmea = {0}

Detailed Description

Basic parser for the NMEA protocol.

Status: Parsing GGA, RMC, GSA and GSV.

Definition in file gps_nmea.c.

Macro Definition Documentation

◆ GOT_CHECKSUM

#define GOT_CHECKSUM   2

Definition at line 56 of file gps_nmea.c.

Referenced by gps_skytraq_parse(), and nmea_parse_char().

◆ GOT_END

#define GOT_END   3

Definition at line 57 of file gps_nmea.c.

Referenced by nmea_parse_char().

◆ GOT_START

#define GOT_START   1

Definition at line 55 of file gps_nmea.c.

Referenced by nmea_parse_char(), and xsens_parser_func().

◆ NMEA_PRINT

#define NMEA_PRINT ( ...)

◆ WAIT

#define WAIT   0

Definition at line 54 of file gps_nmea.c.

Referenced by nmea_parse_char(), and nmea_parse_msg().

Function Documentation

◆ gps_nmea_event()

void gps_nmea_event ( void )

Definition at line 78 of file gps_nmea.c.

References dev, gps_nmea, nmea_configure(), nmea_gps_msg(), and nmea_parse_char().

Here is the call graph for this function:

◆ gps_nmea_init()

void gps_nmea_init ( void )

Definition at line 66 of file gps_nmea.c.

References gps_nmea, GPS_NMEA_NB_CHANNELS, nmea_configure(), and nmea_parse_prop_init().

Here is the call graph for this function:

◆ nmea_calc_crc()

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:

◆ nmea_configure()

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 gps_nmea.

Referenced by gps_nmea_event(), and gps_nmea_init().

Here is the caller graph for this function:

◆ nmea_gps_msg()

void nmea_gps_msg ( void )

Definition at line 95 of file gps_nmea.c.

References get_sys_time_usec(), GPS_FIX_3D, gps_nmea, GPS_NMEA_ID, sys_time::nb_sec, sys_time::nb_sec_rem, and nmea_parse_msg().

Referenced by gps_nmea_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nmea_parse_char()

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, NMEA_MAXLEN, NMEA_PRINT, and WAIT.

Referenced by gps_nmea_event().

Here is the caller graph for this function:

◆ nmea_parse_GGA()

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, ecef_of_lla_f(), gps_nmea, GPS_VALID_HMSL_BIT, GPS_VALID_POS_ECEF_BIT, GPS_VALID_POS_LLA_BIT, LlaCoor_f::lat, LlaCoor_f::lon, NMEA_PRINT, nmea_read_until(), EcefCoor_f::x, EcefCoor_f::y, and EcefCoor_f::z.

Referenced by nmea_parse_msg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nmea_parse_GSA()

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 gps_nmea, NMEA_PRINT, and nmea_read_until().

Referenced by nmea_parse_msg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nmea_parse_GSV()

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 gps_nmea, NMEA_PRINT, and nmea_read_until().

Referenced by nmea_parse_msg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nmea_parse_msg()

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, nmea_parse_GGA(), nmea_parse_GSA(), nmea_parse_GSV(), nmea_parse_prop_msg(), nmea_parse_RMC(), NMEA_PRINT, and WAIT.

Referenced by nmea_gps_msg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nmea_parse_prop_init()

void WEAK nmea_parse_prop_init ( void )

Definition at line 118 of file gps_nmea.c.

Referenced by gps_nmea_init().

Here is the caller graph for this function:

◆ nmea_parse_prop_msg()

bool WEAK nmea_parse_prop_msg ( void )

Definition at line 122 of file gps_nmea.c.

Referenced by nmea_parse_msg().

Here is the caller graph for this function:

◆ nmea_parse_RMC()

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, gps_nmea, GPS_VALID_COURSE_BIT, NMEA_PRINT, and nmea_read_until().

Referenced by nmea_parse_msg().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ gps_nmea