2956 |
poskozby |
1 |
/*Z dane NMEA zpravy vypreparuje potrebne informace*/ |
|
|
2 |
/*Autor: Zbynek*/ |
|
|
3 |
#include "GPS_dekoduj.h" |
|
|
4 |
#include <string.h> |
|
|
5 |
NMEA_GPRMC GPRMC_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, m = 0; |
|
|
17 |
uint8_t pocet_carek = 0; |
|
|
18 |
uint8_t po_tecce = 0; |
|
|
19 |
for ( i = 0; i < NMEA_delka; i++) |
|
|
20 |
{ |
|
|
21 |
if (pocet_carek == 1) |
|
|
22 |
{ |
|
|
23 |
|
|
|
24 |
if(NMEA_retezec[i] == '.') |
|
|
25 |
po_tecce = 1; |
|
|
26 |
if (po_tecce == 0) |
|
|
27 |
{ |
|
|
28 |
if (j == 2 || j == 5) |
|
|
29 |
{ |
|
|
30 |
GPRMC_informace.UTC_time[j] = ':'; |
|
|
31 |
j++; |
|
|
32 |
} |
|
|
33 |
GPRMC_informace.UTC_time[j] = NMEA_retezec[i]; |
|
|
34 |
j++; |
|
|
35 |
} |
|
|
36 |
} |
|
|
37 |
else if (pocet_carek == 2) |
|
|
38 |
{ |
|
|
39 |
GPRMC_informace.Status_GPS[0] = NMEA_retezec[i-1]; |
|
|
40 |
} |
|
|
41 |
else if (pocet_carek == 3 || pocet_carek == 4) |
|
|
42 |
{ |
|
|
43 |
GPRMC_informace.Latitude[k] = NMEA_retezec[i]; |
|
|
44 |
k++; |
|
|
45 |
} |
|
|
46 |
else if (pocet_carek == 5 || pocet_carek == 6) |
|
|
47 |
{ |
|
|
48 |
GPRMC_informace.Longitude[l] = NMEA_retezec[i]; |
|
|
49 |
l++; |
|
|
50 |
} |
|
|
51 |
else if (pocet_carek == 9) |
|
|
52 |
{ |
|
|
53 |
if (m == 2 || m == 5) |
|
|
54 |
{ |
|
|
55 |
GPRMC_informace.Datum[m] = '.'; |
|
|
56 |
m++; |
|
|
57 |
} |
|
|
58 |
GPRMC_informace.Datum[m] = NMEA_retezec[i]; |
|
|
59 |
m++; |
|
|
60 |
} |
|
|
61 |
if (NMEA_retezec[i] == ',') |
|
|
62 |
{ |
|
|
63 |
pocet_carek++; |
|
|
64 |
} |
|
|
65 |
if (pocet_carek >9) |
|
|
66 |
{ |
|
|
67 |
GPRMC_informace.UTC_time[j] = 0; |
|
|
68 |
GPRMC_informace.Latitude[k-1] = 0; |
|
|
69 |
GPRMC_informace.Longitude[l-1] = 0; |
|
|
70 |
GPRMC_informace.Datum[m-1] = 0; |
|
|
71 |
GPRMC_informace.Status_GPS[1] = 0; |
|
|
72 |
i = 0, j = 0, k = 0, l = 0, m = 0; |
|
|
73 |
po_tecce = 0; |
|
|
74 |
break; // nema vyznam dal zapisovat, potrebne je ulozeno. |
|
|
75 |
} |
|
|
76 |
} |
|
|
77 |
} |