mirror of
https://github.com/RobotechLille/cdf2018-principal
synced 2024-12-24 14:40:37 +01:00
Gestion des signaux
This commit is contained in:
parent
4af0f8c865
commit
f3c90fad06
|
@ -23,7 +23,6 @@ void startIHM()
|
|||
{
|
||||
configureButtons();
|
||||
pthread_create(&tIHM, NULL, TaskIHM, NULL);
|
||||
pthread_join(tIHM, NULL);
|
||||
}
|
||||
|
||||
// t1 - t2
|
||||
|
@ -203,6 +202,7 @@ void* TaskIHM(void* pdata)
|
|||
|
||||
void deconfigureIHM()
|
||||
{
|
||||
pthread_cancel(tIHM);
|
||||
clearLCD();
|
||||
printToLCD(LCD_LINE_1, "Bye bye!");
|
||||
}
|
||||
|
|
|
@ -71,13 +71,14 @@ int freewheel()
|
|||
sendCF(C2FD_PWM, &msgFree, sizeof(struct C2FD_PWMs));
|
||||
}
|
||||
|
||||
void deconfigureMovement()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int stop()
|
||||
{
|
||||
brake();
|
||||
// TODO Actionneurs
|
||||
}
|
||||
|
||||
void deconfigureMovement()
|
||||
{
|
||||
stop();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h> // random seed
|
||||
|
@ -7,34 +8,51 @@
|
|||
|
||||
#include "CF.h"
|
||||
#include "debug.h"
|
||||
#include "i2c.h"
|
||||
#include "ihm.h"
|
||||
#include "movement.h"
|
||||
#include "position.h"
|
||||
|
||||
pthread_mutex_t sRunning;
|
||||
|
||||
void endRunning(int signal)
|
||||
{
|
||||
(void)signal;
|
||||
printf("21\n");
|
||||
pthread_mutex_unlock(&sRunning);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
printf("Démarrage...\n");
|
||||
if (wiringPiSetup() < 0) {
|
||||
fprintf(stderr, "Impossible d'initialiser WiringPi\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
initI2C();
|
||||
configureIHM();
|
||||
|
||||
srand(time(NULL));
|
||||
|
||||
configureIHM();
|
||||
configureDebug();
|
||||
configureCF();
|
||||
configureMovement();
|
||||
configurePosition();
|
||||
startDebug();
|
||||
|
||||
startIHM();
|
||||
|
||||
// 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();
|
||||
deconfigureMovement();
|
||||
deconfigurePosition();
|
||||
deconfigureCF();
|
||||
deconfigureIHM();
|
||||
deconfigureDebug();
|
||||
deconfigureIHM();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue