Larus glider flight sensor system 3.9.2024
Software-In-The-Loop test and validation system
Loading...
Searching...
No Matches
NMEA_format.cpp File Reference

ASCII converters for NMEA string output. More...

#include "NMEA_format.h"
#include "ascii_support.h"
#include "embedded_math.h"

Go to the source code of this file.

Macros

#define ANGLE_SCALE   1e-7f
 
#define MPS_TO_NMPH   1.944f
 
#define RAD_TO_DEGREE_10   572.958f
 
#define RAD_TO_DEGREE   57.2958f
 
#define METER_TO_FEET   3.2808f
 
#define MPS_TO_KMPH   3.6f
 

Functions

char hex4 (uint8_t data)
 
charNMEA_append_tail (char *p)
 add end delimiter, evaluate and add checksum and add CR+LF
 
charto_ascii_2_decimals (int32_t number, char *s)
 
charto_ascii_1_decimal (int32_t number, char *s)
 
void angle_format (double angle, char posc, char negc, char *&p)
 append an angle in ASCII into a NMEA string
 
void format_GNSS_timestamp (const coordinates_t &coordinates, char *&p)
 
void format_RMC (const coordinates_t &coordinates, char *&p)
 NMEA-format time, position, groundspeed, track data.
 
void format_GGA (const coordinates_t &coordinates, char *&p)
 NMEA-format position report, sat number and GEO separation.
 
void format_PLARD (float density, char type, char *&p)
 
void format_PLARB (float voltage, char *&p)
 
void format_PLARA (float roll, float pitch, float yaw, char *&p)
 
void format_PLARW (float wind_north, float wind_east, char windtype, char *&p)
 format wind reporting NMEA sequence
 
void format_PLARV (float variometer, float avg_variometer, float pressure_altitude, float TAS, char *&p)
 TEK vario, average vario, pressure altitude and speed (TAS)
 
void format_PLARS (float value, PLARS_TYPES option, char *&p)
 format setting NMEA for MacCready, Ballast, Bugs, QNH
 
bool NMEA_checksum (const char *line)
 test a line for valid NMEA checksum
 
void format_NMEA_string_fast (const output_data_t &output_data, string_buffer_t &NMEA_buf, bool horizon_available)
 this procedure formats all our NMEA sequences
 
void format_NMEA_string_slow (const output_data_t &output_data, string_buffer_t &NMEA_buf)
 this procedure formats all our NMEA sequences
 

Variables

ROM char HEX [] ="0123456789ABCDEF"
 
ROM char GPRMC [] ="$GPRMC,"
 
ROM char GPGGA [] ="$GPGGA,"
 
ROM char PLARD [] ="$PLARD,"
 
ROM char PLARB [] ="$PLARB,"
 
ROM char PLARA [] ="$PLARA,"
 
ROM char PLARW [] ="$PLARW,"
 
ROM char PLARV [] ="$PLARV,"
 
ROM char PLARS [] ="$PLARS,L,"
 
ROM char PLARS_MC [] ="MC,"
 
ROM char PLARS_BAL [] ="BAL,"
 
ROM char PLARS_BUGS [] ="BUGS,"
 
ROM char PLARS_QNH [] ="QNH,"
 

Detailed Description

ASCII converters for NMEA string output.

Author
Dr. Klaus Schaefer

<Larus Flight Sensor Firmware>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file NMEA_format.cpp.

Macro Definition Documentation

◆ ANGLE_SCALE

#define ANGLE_SCALE   1e-7f

Definition at line 29 of file NMEA_format.cpp.

◆ METER_TO_FEET

#define METER_TO_FEET   3.2808f

Definition at line 33 of file NMEA_format.cpp.

◆ MPS_TO_KMPH

#define MPS_TO_KMPH   3.6f

Definition at line 34 of file NMEA_format.cpp.

◆ MPS_TO_NMPH

#define MPS_TO_NMPH   1.944f

Definition at line 30 of file NMEA_format.cpp.

◆ RAD_TO_DEGREE

#define RAD_TO_DEGREE   57.2958f

Definition at line 32 of file NMEA_format.cpp.

◆ RAD_TO_DEGREE_10

#define RAD_TO_DEGREE_10   572.958f

Definition at line 31 of file NMEA_format.cpp.

Function Documentation

◆ angle_format()

void angle_format ( double  angle,
char  posc,
char  negc,
char *&  p 
)

append an angle in ASCII into a NMEA string

Definition at line 105 of file NMEA_format.cpp.

Referenced by format_GGA(), and format_RMC().

◆ format_GGA()

◆ format_GNSS_timestamp()

void format_GNSS_timestamp ( const coordinates_t coordinates,
char *&  p 
)

Definition at line 151 of file NMEA_format.cpp.

References coordinates_t::hour, coordinates_t::minute, and coordinates_t::second.

Referenced by format_GGA(), and format_RMC().

◆ format_NMEA_string_fast()

void format_NMEA_string_fast ( const output_data_t output_data,
string_buffer_t NMEA_buf,
bool  horizon_available 
)

this procedure formats all our NMEA sequences

combine all data to be output to the NMEA port

Definition at line 436 of file NMEA_format.cpp.

References EAST, format_PLARA(), format_PLARV(), format_PLARW(), NORTH, and ZERO.

◆ format_NMEA_string_slow()

void format_NMEA_string_slow ( const output_data_t output_data,
string_buffer_t NMEA_buf 
)

this procedure formats all our NMEA sequences

Definition at line 461 of file NMEA_format.cpp.

References EAST, format_GGA(), format_PLARB(), format_PLARD(), format_PLARW(), format_RMC(), and NORTH.

◆ format_PLARA()

void format_PLARA ( float  roll,
float  pitch,
float  yaw,
char *&  p 
)

◆ format_PLARB()

void format_PLARB ( float  voltage,
char *&  p 
)

Definition at line 292 of file NMEA_format.cpp.

References append_string(), NMEA_append_tail(), PLARB, and to_ascii_2_decimals().

Referenced by format_NMEA_string_slow().

◆ format_PLARD()

void format_PLARD ( float  density,
char  type,
char *&  p 
)

Definition at line 278 of file NMEA_format.cpp.

References append_string(), NMEA_append_tail(), PLARD, and to_ascii_2_decimals().

Referenced by format_NMEA_string_slow().

◆ format_PLARS()

void format_PLARS ( float  value,
PLARS_TYPES  option,
char *&  p 
)

format setting NMEA for MacCready, Ballast, Bugs, QNH

Definition at line 389 of file NMEA_format.cpp.

References append_string(), BAL, BUGS, MC, NMEA_append_tail(), PLARS, PLARS_BAL, PLARS_BUGS, PLARS_MC, PLARS_QNH, QNH, to_ascii_1_decimal(), and to_ascii_2_decimals().

◆ format_PLARV()

void format_PLARV ( float  variometer,
float  avg_variometer,
float  pressure_altitude,
float  TAS,
char *&  p 
)

TEK vario, average vario, pressure altitude and speed (TAS)

Definition at line 359 of file NMEA_format.cpp.

References append_string(), format_integer(), MPS_TO_KMPH, NMEA_append_tail(), PLARV, and to_ascii_2_decimals().

Referenced by format_NMEA_string_fast().

◆ format_PLARW()

void format_PLARW ( float  wind_north,
float  wind_east,
char  windtype,
char *&  p 
)

format wind reporting NMEA sequence

Definition at line 323 of file NMEA_format.cpp.

References append_string(), ATAN2, format_integer(), MPS_TO_KMPH, NEGLECTABLE_WIND, NMEA_append_tail(), PLARW, RAD_TO_DEGREE, SQR, and SQRT.

Referenced by format_NMEA_string_fast(), and format_NMEA_string_slow().

◆ format_RMC()

◆ hex4()

char hex4 ( uint8_t  data)
inline

Definition at line 39 of file NMEA_format.cpp.

References HEX.

Referenced by NMEA_append_tail(), and NMEA_checksum().

◆ NMEA_append_tail()

char * NMEA_append_tail ( char p)

add end delimiter, evaluate and add checksum and add CR+LF

Definition at line 45 of file NMEA_format.cpp.

References assert, and hex4().

Referenced by format_GGA(), format_PLARA(), format_PLARB(), format_PLARD(), format_PLARS(), format_PLARV(), format_PLARW(), and format_RMC().

◆ NMEA_checksum()

bool NMEA_checksum ( const char line)

test a line for valid NMEA checksum

Definition at line 424 of file NMEA_format.cpp.

References hex4().

◆ to_ascii_1_decimal()

char * to_ascii_1_decimal ( int32_t  number,
char s 
)

format an integer into ASCII with one decimal

Parameters
numbervalue * 10

Definition at line 85 of file NMEA_format.cpp.

References format_integer(), HEX, and s.

Referenced by format_GGA(), format_PLARA(), format_PLARS(), and to_ascii_1_decimal().

◆ to_ascii_2_decimals()

char * to_ascii_2_decimals ( int32_t  number,
char s 
)

format an integer into ASCII with exactly two digits after the decimal point

Parameters
numbervalue * 100

Definition at line 62 of file NMEA_format.cpp.

References format_integer(), HEX, and s.

Referenced by format_PLARB(), format_PLARD(), format_PLARS(), format_PLARV(), and to_ascii_2_decimals().

Variable Documentation

◆ GPGGA

ROM char GPGGA[] ="$GPGGA,"

Definition at line 230 of file NMEA_format.cpp.

Referenced by format_GGA().

◆ GPRMC

ROM char GPRMC[] ="$GPRMC,"

Definition at line 171 of file NMEA_format.cpp.

Referenced by format_RMC().

◆ HEX

ROM char HEX[] ="0123456789ABCDEF"

Definition at line 36 of file NMEA_format.cpp.

Referenced by hex4(), to_ascii_1_decimal(), and to_ascii_2_decimals().

◆ PLARA

ROM char PLARA[] ="$PLARA,"

Definition at line 300 of file NMEA_format.cpp.

Referenced by format_PLARA().

◆ PLARB

ROM char PLARB[] ="$PLARB,"

Definition at line 290 of file NMEA_format.cpp.

Referenced by format_PLARB().

◆ PLARD

ROM char PLARD[] ="$PLARD,"

Definition at line 276 of file NMEA_format.cpp.

Referenced by format_PLARD().

◆ PLARS

ROM char PLARS[] ="$PLARS,L,"

Definition at line 383 of file NMEA_format.cpp.

Referenced by format_PLARS().

◆ PLARS_BAL

ROM char PLARS_BAL[] ="BAL,"

Definition at line 385 of file NMEA_format.cpp.

Referenced by format_PLARS().

◆ PLARS_BUGS

ROM char PLARS_BUGS[] ="BUGS,"

Definition at line 386 of file NMEA_format.cpp.

Referenced by format_PLARS().

◆ PLARS_MC

ROM char PLARS_MC[] ="MC,"

Definition at line 384 of file NMEA_format.cpp.

Referenced by format_PLARS().

◆ PLARS_QNH

ROM char PLARS_QNH[] ="QNH,"

Definition at line 387 of file NMEA_format.cpp.

Referenced by format_PLARS().

◆ PLARV

ROM char PLARV[] ="$PLARV,"

Definition at line 356 of file NMEA_format.cpp.

Referenced by format_PLARV().

◆ PLARW

ROM char PLARW[] ="$PLARW,"

Definition at line 320 of file NMEA_format.cpp.

Referenced by format_PLARW().