-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
executable file
·59 lines (41 loc) · 1.19 KB
/
main.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
// Tether Control of Uav
// Ground Station
//
// BS.c. Project
// Danish Technical University
// Peter Savnik
// 2014-2015
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <phidget21.h>
#include "global.h"
#include "phidget.h"
#include "display.h"
int main(int argc, char** argv)
{
printf("Ground station started\n");
stop = 0;
pthread_t *threadData;
pthread_t *threadDisplay;
char key;
dataRate = 100; // [ms] [8:1000]
dataFilter = 0; // see updateAngle
int threadData_check = pthread_create(&threadData, NULL, GetAngle, NULL);
if(threadData_check != 0) puts("ERROR: pthread Data (getAngle) failed");
int threadDisplay_check = pthread_create(&threadDisplay, NULL, display, NULL);
if(threadDisplay_check != 0) puts("ERROR: pthread Display (terminal interface) failed");
while(stop == 0){
key = '1';
if(key == 'c'){
stop == 1;
}
}
stop = 1;
sleep(1); // Magic number ensures phreads has time to stop
pthread_join(&threadData, NULL);
pthread_join(&threadDisplay, NULL);
puts("INFO: pthread finished");
return 0;
}