-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGPS_base_station.c
52 lines (40 loc) · 1.4 KB
/
GPS_base_station.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
#include "serial_telemetry.h"
struct gpsData data_gps;
struct dataPoint data_telemetry;
struct basic time_code;
int main(){
//////////////////
// Setup Serial //
//////////////////
int gps_or_sensors;
char *portname = "/dev/ttyACM0"; // Trenton's Laptop "/dev/ttyS11"; //Trenton's Desktop
int fd = setup_serial(portname);
if(fd == -1) // if errors in setup_serial exit
return -1;
/////////////////////////////
// Gather serial telemetry //
/////////////////////////////
printf("\nWaiting for GPS data\n\n");
while(1){
gps_or_sensors = gather_telemetry(fd,&time_code,&data_telemetry,&data_gps);
if(gps_or_sensors == 0){
// time_code and data_telemetry was updated
// do stuff
// printf("acc_x : %f\n", data_telemetry.acc.x);
//printf("pressure : %f\n", data_telemetry.prs);
// printf("temperature : %f\n", data_telemetry.tmp);
}
else if(gps_or_sensors == 1){
// time_code and data_gps was updated
//do other stuff
printf("latitude : %f\n", data_gps.latitude);
printf("longitude : %f\n", data_gps.longitude);
}
else{ // if gather_telemetry failed
return -1;
}
//printf("time: %i\n", time_code.time);
//printf("code: %i\n", time_code.code);
}
return 0;
}