-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcomma_parser.c
More file actions
73 lines (65 loc) · 1.05 KB
/
comma_parser.c
File metadata and controls
73 lines (65 loc) · 1.05 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <stdio.h>
#include <stdint.h>
#include <string.h>
void ProcessGPRMC(char *pData);
int main(void)
{
char data[] = "GPRMC,123519,A,4807.038,N,01131.000,E,022.4,084.4,230394,003.1,W*6A";
ProcessGPRMC(&data[0]);
return 0;
}
char rmcmessage[50];
char date[6];
char time1[9];
char lat[10];
char lng[11];
void ProcessGPRMC(char *pData)
{
char *pchar;
char *str;
int CommaCount;
int len;
strcpy(rmcmessage, pData);
len= strlen(rmcmessage);
str = pData;
pchar = str;
while(len)
{
len--;
if(*str == ',')
{
CommaCount++;
*str = '\0';
if(pchar == str)
{
pchar = str + 1;
printf("here");
continue;
}
switch(CommaCount)
{
case 2:
strcpy(time1, pchar);
time1[6] = '\0';
printf("\n%s",time1);
break;
case 4:
strcpy(lat,pchar);
printf("\n%s",lat);
break;
case 6:
strcpy(lng,pchar);
printf("\n%s",lng);
break;
case 10:
strcpy(date,pchar);
printf("\n%s",date);
break;
default:
break;
}
pchar = str + 1;
}
str++;
}
}