1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
| char gsm_data[] = "$GPGGA,124545.000,1954.3693,N,07520.6932,E,1,05,3. 7,606.4,M,-
64.3,M,,0000*7E\r\n"
#define _LATITUDE 0
#define _LONGITUDE 1
char latitude[15], longitude[15], NS_EW[];
void Get_Latitude_Or_Longitude(char *s1, char *s2, char *s3, char option) {
char i = 0;
while(*s1) {
if(*s1 == ',') {
++i;
}
if(option == 0) {
if(i == 2) {
*s++;
break;
}
}
if(option == 1) {
if(i == 4) {
*s++;
break;
}
}
*s++;
}
while(*s != ',') {
*s2++ = *s1++;
}
*s1++;
*s3 = *s1;
}
//usage
while(1) {
Get_Latitude_Or_Longitude(gps_data, latitude, NS_EW, _LATITUDE);
//print latitude[] and NS_EW[]
Get_Latitude_Or_Longitude(gps_data, longitude, NS_EW, _LONGITUDE);
//print longitude[] and NS_EW[]
} |