/Designs/Measuring_instruments/ABL01A/SW/Pozemni stanice/Zkouska - STM32L152-DISCOVERY/keil/GPS_dekoduj.c
0,0 → 1,63
/*Z dane NMEA zpravy vypreparuje potrebne informace*/
/*Autor: Zbynek*/
#include "GPS_dekoduj.h"
#include <string.h>
NMEA_GPGGA GPGGA_informace;
 
/************************************************************************
* Funkce: dekoduj_zpravu_GPS
* Ucel: Z RX0_buffer vytahne informace o soucasne poloze, je tam ulozena cela veta RMC
* Vstup: Zadny
* Vystup: Zadny
************************************************************************/
void dekoduj_zpravu_GPS (uint8_t* NMEA_retezec, uint8_t NMEA_delka)
{
 
uint8_t i = 0, j = 0, k = 0, l = 0;
uint8_t pocet_carek = 0;
for ( i = 0; i < NMEA_delka; i++)
{
if (pocet_carek == 1)
{
GPGGA_informace.UTC_time[l] = NMEA_retezec[i];
l++;
}
if (pocet_carek == 2 || pocet_carek == 3)
{
GPGGA_informace.Latitude[k] = NMEA_retezec[i];
k++;
l = 0;
}
if (pocet_carek == 4 || pocet_carek == 5)
{
 
GPGGA_informace.Longitude[j] = NMEA_retezec[i];
j++;
}
if (pocet_carek == 6)
{
GPGGA_informace.UTC_time[l-1] = 0;
GPGGA_informace.Latitude[k-1] = 0;
GPGGA_informace.Longitude[j-1] = 0;
 
GPGGA_informace.Status_GPS = NMEA_retezec[i-1];
j = 0;
}
if (pocet_carek == 9)
{
GPGGA_informace.Altitude[j] = NMEA_retezec[i];
j++;
}
if (NMEA_retezec[i] == ',')
{
pocet_carek++;
}
if (pocet_carek >9)
{
GPGGA_informace.Altitude[j-1] = 0; // konec Stringu
break; // nema vyznam dal zapisovat, potrebne je ulozeno.
}
}
}