2018-02-16 15:44:45 +01:00
|
|
|
#include <pthread.h>
|
2018-05-01 09:03:33 +02:00
|
|
|
#include <signal.h>
|
2018-04-30 16:15:47 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <time.h> // random seed
|
2018-02-16 15:44:45 +01:00
|
|
|
#include <unistd.h> // sleep
|
2018-04-30 16:15:47 +02:00
|
|
|
#include <wiringPi.h>
|
2018-02-07 17:57:01 +01:00
|
|
|
|
2018-04-04 16:17:13 +02:00
|
|
|
#include "CF.h"
|
2018-04-30 16:15:47 +02:00
|
|
|
#include "debug.h"
|
2018-05-01 09:03:33 +02:00
|
|
|
#include "i2c.h"
|
2018-04-30 16:15:47 +02:00
|
|
|
#include "ihm.h"
|
2018-02-16 15:44:45 +01:00
|
|
|
#include "movement.h"
|
2018-04-04 16:17:13 +02:00
|
|
|
#include "position.h"
|
2018-02-12 19:23:24 +01:00
|
|
|
|
2018-05-01 09:03:33 +02:00
|
|
|
pthread_mutex_t sRunning;
|
|
|
|
|
|
|
|
void endRunning(int signal)
|
|
|
|
{
|
|
|
|
(void)signal;
|
|
|
|
printf("21\n");
|
|
|
|
pthread_mutex_unlock(&sRunning);
|
|
|
|
}
|
|
|
|
|
2018-02-12 19:23:24 +01:00
|
|
|
int main()
|
|
|
|
{
|
2018-02-16 15:44:45 +01:00
|
|
|
|
2018-04-30 16:15:47 +02:00
|
|
|
if (wiringPiSetup() < 0) {
|
|
|
|
fprintf(stderr, "Impossible d'initialiser WiringPi\n");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
initI2C();
|
|
|
|
srand(time(NULL));
|
2018-05-01 09:03:33 +02:00
|
|
|
|
|
|
|
configureIHM();
|
2018-02-16 15:44:45 +01:00
|
|
|
configureDebug();
|
2018-05-01 08:45:02 +02:00
|
|
|
configureCF();
|
|
|
|
configureMovement();
|
|
|
|
configurePosition();
|
2018-04-29 09:38:49 +02:00
|
|
|
startDebug();
|
2018-04-30 16:15:47 +02:00
|
|
|
startIHM();
|
2018-02-16 22:13:24 +01:00
|
|
|
|
2018-05-01 09:03:33 +02:00
|
|
|
// Bloque jusqu'à l'arrivée d'un signal
|
|
|
|
pthread_mutex_init(&sRunning, NULL);
|
|
|
|
signal(SIGINT, endRunning);
|
|
|
|
signal(SIGTERM, endRunning);
|
|
|
|
signal(SIGQUIT, endRunning);
|
|
|
|
pthread_mutex_lock(&sRunning);
|
|
|
|
pthread_mutex_lock(&sRunning);
|
|
|
|
|
|
|
|
deconfigureMovement();
|
2018-05-01 08:45:02 +02:00
|
|
|
deconfigureMovement();
|
|
|
|
deconfigurePosition();
|
|
|
|
deconfigureCF();
|
2018-04-29 09:38:49 +02:00
|
|
|
deconfigureDebug();
|
2018-05-01 09:03:33 +02:00
|
|
|
deconfigureIHM();
|
2018-02-16 15:44:45 +01:00
|
|
|
return EXIT_SUCCESS;
|
2018-02-07 17:57:01 +01:00
|
|
|
}
|