-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse.c
71 lines (49 loc) · 1.58 KB
/
parse.c
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "parse.h"
int parse(struct NMEAData* dataStore, struct NMEAMessage * sentence) {
// chop off the first section of the comma-delimited sentence
// and store it in a new string
if (strcmp(sentence->type, "GPGGA") == 0) {
return parseGGA(dataStore, sentence->data);
} else if (strcmp(sentence->type, "GPGLL") == 0) {
return parseGLL(dataStore, sentence->data);
} else if (strcmp(sentence->type, "GPGSV") == 0) {
return parseGSV(dataStore, sentence->data);
} else if (strcmp(sentence->type, "GPRMC") == 0) {
return parseRMC(dataStore, sentence->data);
} else if (strcmp(sentence->type, "GPZDA") == 0) {
return parseZDA(dataStore, sentence->data);
} else {
// We didn't get a message we care about.
return 1;
}
} // end parse()
void convertLon(char* dest, char* temp) {
dest[0] = temp[0]; // d
dest[1] = temp[1]; // d
dest[2] = temp[2]; // d
dest[3] = 'o'; // o
dest[4] = temp[3]; // m
dest[5] = temp[4]; // m
dest[6] = '.';
dest[7] = temp[6];
dest[8] = temp[7];
dest[9] = temp[8];
dest[10] = '\0';
}
void convertLat(char* dest, char* temp) {
dest[0] = '0'; // d
dest[1] = temp[0]; // d
dest[2] = temp[1]; // d
dest[3] = 'o'; // o
dest[4] = temp[2]; // m
dest[5] = temp[3]; // m
dest[6] = '.'; // .
dest[7] = temp[5]; // s
dest[8] = temp[6]; // s
dest[9] = temp[7]; // s
dest[10] = '\0';
}