46 #define NMEA_PRINT(...) {};
49 #if NMEA_PRINT == printf
56 #define GOT_CHECKSUM 2
80 struct link_device *
dev = &((NMEA_GPS_LINK).device);
86 while (dev->char_available(dev->periph)) {
135 bool msg_valid =
false;
205 NMEA_PRINT(
"nmea_parse_char: skipping incomplete msg: len=%i, \"%s\"\n\r",
218 NMEA_PRINT(
"nmea_parse_char: msg too long, len=%i, \"%s\"\n\r",
232 NMEA_PRINT(
"nmea_parse_char: this should not happen!");
248 for (it = 0; it < buff_sz; ++it) {
267 NMEA_PRINT(
"p_GSA() - skipping empty message\n\r");
287 for (prn_cnt = 0; prn_cnt < 12; prn_cnt++) {
290 NMEA_PRINT(
"p_GSA() - PRN %i=%i\n\r", satcount, prn);
311 float hdop __attribute__((unused)) = strtof(&
gps_nmea.
msg_buf[i], NULL);
316 float vdop __attribute__((unused)) = strtof(&
gps_nmea.
msg_buf[i], NULL);
336 NMEA_PRINT(
"p_RMC() - skipping empty message\n\r");
366 NMEA_PRINT(
"p_RMC() - course: %f deg\n\r", course);
383 double degrees, minutesfrac;
388 NMEA_PRINT(
"p_GGA() - skipping empty message\n\r");
402 minutesfrac = modf(lat / 100, °rees);
403 lat = degrees + (minutesfrac * 100) / 60;
412 lla_f.
lat = RadOfDeg(lat);
414 NMEA_PRINT(
"p_GGA() - lat=%f gps_lat=%f\n\r", (lat * 1000), lla_f.
lat);
421 minutesfrac = modf(lon / 100, °rees);
422 lon = degrees + (minutesfrac * 100) / 60;
431 lla_f.
lon = RadOfDeg(lon);
441 NMEA_PRINT(
"p_GGA() - POS_AVAILABLE == TRUE\n\r");
443 NMEA_PRINT(
"p_GGA() - gps_pos_available == false\n\r");
469 NMEA_PRINT(
"p_GGA() - geoid alt=%f\n\r", geoid);
471 lla_f.
alt = hmsl + geoid;
504 NMEA_PRINT(
"p_GSV() - skipping empty message\n\r");
511 bool is_glonass =
false;
518 NMEA_PRINT(
"p_GSV() - %i sentences\n\r", nb_sen);
523 NMEA_PRINT(
"p_GSV() - sentence=%i\n\r", cur_sen);
528 NMEA_PRINT(
"p_GSV() - num_sat=%i\n\r", num_sat);
533 for (sat_cnt = 0; sat_cnt < 4; sat_cnt++) {
545 int ch_idx = (cur_sen - 1) * 4 + sat_cnt;
547 if (!is_glonass && ch_idx > 0 && ch_idx < 12) {
554 NMEA_PRINT(
"p_GSV() - GLONASS %i PRN=%i elev=%i azim=%i snr=%i\n\r", ch_idx, prn, elev, azim, snr);
557 NMEA_PRINT(
"p_GSV() - GPS %i PRN=%i elev=%i azim=%i snr=%i\n\r", ch_idx, prn, elev, azim, snr);
bool msg_available
flag set to TRUE if a new msg/sentence is available to be parsed
struct SVinfo svinfos[GPS_NB_CHANNELS]
holds information from the Space Vehicles (Satellites)
int16_t azim
azimuth in deg
uint8_t nb_channels
Number of scanned satellites.
vector in EarthCenteredEarthFixed coordinates
uint8_t valid_fields
bitfield indicating valid fields (GPS_VALID_x_BIT)
static bool nmea_parse_GSV(void)
Parse GSV-nmea-messages.
static bool nmea_parse_RMC(void)
Parse RMC NMEA messages.
void WEAK nmea_parse_prop_init(void)
char msg_buf[NMEA_MAXLEN]
buffer for storing one nmea-line
Main include for ABI (AirBorneInterface).
#define GPS_NMEA_NB_CHANNELS
static void nmea_read_until(int *i)
Read until a certain character, placed here for proprietary includes.
bool WEAK nmea_parse_prop_msg(void)
uint8_t svid
Satellite ID.
#define GPS_FIX_3D
3D GPS fix
bool nmea_parse_msg(void)
nmea_parse_char() has a complete line.
void gps_nmea_event(void)
uint8_t gps_nb_ovrn
number if incomplete nmea-messages
uint32_t last_3dfix_ticks
cpu time ticks at last valid 3D fix
int8_t elev
elevation in deg
void nmea_parse_char(uint8_t c)
This is the actual parser.
int32_t alt
in millimeters above WGS84 reference ellipsoid
uint32_t last_msg_time
cpu time in sec at last received GPS message
Paparazzi floating point math for geodetic calculations.
#define GPS_VALID_COURSE_BIT
vector in Latitude, Longitude and Altitude
bool have_gsv
flag set to TRUE if GPGSV message received
int32_t hmsl
height above mean sea level (MSL) in mm
uint8_t cno
Carrier to Noise Ratio (Signal Strength) in dbHz.
uint32_t tow
GPS time of week in ms.
Device independent GPS code (interface)
uint16_t pdop
position dilution of precision scaled by 100
static bool nmea_parse_GGA(void)
Parse GGA NMEA messages.
struct EcefCoor_i ecef_pos
position in ECEF in cm
#define GPS_VALID_HMSL_BIT
int32_t lon
in degrees*1e7
void ecef_of_lla_f(struct EcefCoor_f *out, struct LlaCoor_f *in)
volatile uint32_t nb_sec_rem
remainder of seconds since startup in CPU_TICKS
uint8_t status
line parser status
NMEA protocol specific code.
static const struct usb_device_descriptor dev
float alt
in meters (normally above WGS84 reference ellipsoid)
uint32_t last_3dfix_time
cpu time in sec at last valid 3D fix
void WEAK nmea_configure(void)
The function to be called when a characted from the device is available.
static bool nmea_parse_GSA(void)
Parse GSA NMEA messages.
int32_t course
GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north)
volatile uint32_t nb_sec
full seconds since startup
uint8_t nmea_calc_crc(const char *buff, int buff_sz)
Calculate control sum of binary buffer.
bool is_configured
flag set to TRUE if configuration is finished
#define GPS_VALID_POS_ECEF_BIT
uint32_t last_msg_ticks
cpu time ticks at last received GPS message
#define GPS_VALID_POS_LLA_BIT
uint8_t num_sv
number of sat in fix
arch independent LED (Light Emitting Diodes) API
uint16_t gspeed
norm of 2d ground speed in cm/s
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
int32_t lat
in degrees*1e7
uint8_t buff[25]
Buffer used for general comunication over SPI (in buffer)