-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
141 lines (101 loc) · 3.43 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// main.c
//
//
/*+--------------------------------------------------------------+
| SYSTEM INCLUDES |
+--------------------------------------------------------------+*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <time.h>
/*+--------------------------------------------------------------+
| SPECIFIC INCLUDES |
+--------------------------------------------------------------+*/
#include "debug.h" //file where all debug const are defined
#include "screen.h"
#include "stellarium.h"
#include "gps.h"
#include "nexstar.h"
#include "automate.h"
#include "dht11.h"
/*+--------------------------------------------------------------+
| LOCAL CONSTANTS |
+--------------------------------------------------------------+*/
/*+--------------------------------------------------------------+
| GLOBAL VARIABLES |
+--------------------------------------------------------------+*/
/*+--------------------------------------------------------------+
| LOCAL VARIABLES |
+--------------------------------------------------------------+*/
static pthread_t th_stellarium ;
static pthread_t th_gps ;
static pthread_t th_screen_display ;
static pthread_t th_dht11 ;
//static pthread_t th_dew_not ;
//static pthread_t th_camera ;
//static pthread_t th_focus ;
void *ret;
int main(int argc, char **argv)
{
//#if DEBUG
// just to control data size on RPI
printf("Sizeof short : %d\n", sizeof(short)) ;
printf("Sizeof int : %d\n", sizeof(int)) ;
printf("Sizeof double : %d\n", sizeof(double)) ;
//#endif
// long ra, dec ;
// nexstar_get_precise_ra_dec(&ra, &dec) ;
screen_init();
// screen display server is launched in a dedicated thread
if (pthread_create (&th_screen_display, NULL, p_screen_display_server, "1") < 0)
{
fprintf(stderr, "pthread_create error for thread stellarium_server\n"); exit (1);
}
else
{
printf("stellarium_server launched in a thread ==> Ok !\n");
}
// stellarium server is launched in a dedicated thread
if (pthread_create (&th_stellarium, NULL, p_stellarium_server, "1") < 0)
{
fprintf(stderr, "pthread_create error for thread stellarium_server\n"); exit (1);
}
else
{
printf("stellarium_server launched in a thread ==> Ok !\n");
}
// gps server is launched in a dedicated thread
// stellarium server is launched in a dedicated thread
if (pthread_create (&th_gps, NULL, p_gps_server, "1") < 0)
{
fprintf(stderr, "pthread_create error for thread gps_server\n"); exit (1);
}
else
{
printf("gps_server launched in a thread ==> Ok !\n");
}
// dewnot process is launched in a dedicated thread
if (pthread_create (&th_dht11, NULL, p_dht11, "1") < 0)
{
fprintf(stderr, "pthread_create error for thread dht11_driver\n"); exit (1);
}
else
{
printf("dht11_driver launched in a thread ==> Ok !\n");
}
// camera process is launched in a dedicated thread
automate_init() ;
while(1)
{
// TODO add listen for command control over ssh terminal
//sleep(1);
automate() ;
}
fprintf(stderr,"stellarium_server\n");
(void)pthread_join (th_screen_display, &ret);
(void)pthread_join (th_stellarium, &ret);
(void)pthread_join (th_gps, &ret);
(void)pthread_join (th_dht11, &ret);
return 0;
}