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