2971 |
jichapav |
1 |
/*Z dane NMEA zpravy vypreparuje potrebne informace*/ |
|
|
2 |
/*Autor: Zbynek*/ |
|
|
3 |
#include "GPS_dekoduj.h" |
|
|
4 |
#include <string.h> |
|
|
5 |
NMEA_GPGGA GPGGA_informace; |
|
|
6 |
|
|
|
7 |
/************************************************************************ |
|
|
8 |
* Funkce: dekoduj_zpravu_GPS |
|
|
9 |
* Ucel: Z RX0_buffer vytahne informace o soucasne poloze, je tam ulozena cela veta RMC |
|
|
10 |
* Vstup: Zadny |
|
|
11 |
* Vystup: Zadny |
|
|
12 |
************************************************************************/ |
|
|
13 |
void dekoduj_zpravu_GPS (uint8_t* NMEA_retezec, uint8_t NMEA_delka) |
|
|
14 |
{ |
|
|
15 |
|
|
|
16 |
uint8_t i = 0, j = 0, k = 0, l = 0; |
|
|
17 |
uint8_t pocet_carek = 0; |
|
|
18 |
for ( i = 0; i < NMEA_delka; i++) |
|
|
19 |
{ |
|
|
20 |
if (pocet_carek == 1) |
|
|
21 |
{ |
|
|
22 |
GPGGA_informace.UTC_time[l] = NMEA_retezec[i]; |
|
|
23 |
l++; |
|
|
24 |
} |
|
|
25 |
if (pocet_carek == 2 || pocet_carek == 3) |
|
|
26 |
{ |
|
|
27 |
GPGGA_informace.Latitude[k] = NMEA_retezec[i]; |
|
|
28 |
k++; |
|
|
29 |
l = 0; |
|
|
30 |
} |
|
|
31 |
if (pocet_carek == 4 || pocet_carek == 5) |
|
|
32 |
{ |
|
|
33 |
|
|
|
34 |
GPGGA_informace.Longitude[j] = NMEA_retezec[i]; |
|
|
35 |
j++; |
|
|
36 |
} |
|
|
37 |
if (pocet_carek == 6) |
|
|
38 |
{ |
|
|
39 |
GPGGA_informace.UTC_time[l-1] = 0; |
|
|
40 |
GPGGA_informace.Latitude[k-1] = 0; |
|
|
41 |
GPGGA_informace.Longitude[j-1] = 0; |
|
|
42 |
|
|
|
43 |
GPGGA_informace.Status_GPS = NMEA_retezec[i-1]; |
|
|
44 |
j = 0; |
|
|
45 |
} |
|
|
46 |
|
|
|
47 |
if (pocet_carek == 9) |
|
|
48 |
{ |
|
|
49 |
GPGGA_informace.Altitude[j] = NMEA_retezec[i]; |
|
|
50 |
j++; |
|
|
51 |
} |
|
|
52 |
|
|
|
53 |
if (NMEA_retezec[i] == ',') |
|
|
54 |
{ |
|
|
55 |
pocet_carek++; |
|
|
56 |
} |
|
|
57 |
if (pocet_carek >9) |
|
|
58 |
{ |
|
|
59 |
GPGGA_informace.Altitude[j-1] = 0; // konec Stringu |
|
|
60 |
break; // nema vyznam dal zapisovat, potrebne je ulozeno. |
|
|
61 |
} |
|
|
62 |
} |
|
|
63 |
} |