Compare commits

..

1 commit

Author SHA1 Message Date
251b123a6b Final Version 2020-04-06 12:25:17 +02:00
2 changed files with 21 additions and 22 deletions

View file

@ -138,7 +138,6 @@ void Tasks::Init() {
cerr << "Error semaphore create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_sem_create(&sem_startRobotWithoutWatchdog, NULL, 0, S_FIFO)) {
cerr << "Error semaphore create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
@ -556,7 +555,6 @@ void Tasks::OpenComRobot(void *arg) { //PAS DE SOUCIS AU REDEMARAGE
int err;
//bool killOpenComRobotOk = 0;
while (1) { //Is used to restart process
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
// Synchronization barrier (waiting that all tasks are starting)
rt_sem_p(&sem_barrier, TM_INFINITE);
@ -564,6 +562,7 @@ void Tasks::OpenComRobot(void *arg) { //PAS DE SOUCIS AU REDEMARAGE
/**************************************************************************************/
/* The task openComRobot starts here */
/**************************************************************************************/
while (1) { //Is used to restart process
rt_sem_p(&sem_openComRobot, TM_INFINITE);
cout << "Open serial com (";
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
@ -645,7 +644,7 @@ void Tasks::StartRobotTaskWithoutWatchdog(void *arg) {
*/
void Tasks::StartRobotTaskWithWatchdog(void *arg) {
int killBatteryOk=0;
int killBatteryOk;
int cpt=1;
Message * msgSend;
@ -660,6 +659,7 @@ void Tasks::StartRobotTaskWithWatchdog(void *arg) {
//Boolean to get the battery
killBatteryOk = 0;
rt_mutex_acquire(&mutex_killBattery, TM_INFINITE);
killBattery=0;
rt_mutex_release(&mutex_killBattery);
@ -710,9 +710,6 @@ void Tasks::MoveTask(void *arg) {
int rs;
int cpMove;
rt_task_set_periodic(NULL, TM_NOW, 100000000);
while (1) {
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
// Synchronization barrier (waiting that all tasks are starting)
rt_sem_p(&sem_barrier, TM_INFINITE);
@ -720,6 +717,9 @@ void Tasks::MoveTask(void *arg) {
/**************************************************************************************/
/* The task starts here */
/**************************************************************************************/
rt_task_set_periodic(NULL, TM_NOW, 100000000);
while (1) {
rt_task_wait_period(NULL);
cout << "Periodic movement update";
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
@ -752,10 +752,6 @@ void Tasks::DetectLostSupRob(void *arg){
while(1){//Used to restart process
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
// Synchronization barrier (waiting that all tasks are starting)
rt_sem_p(&sem_barrier, TM_INFINITE);
//Wait the Communication with the Robot to be Set
rt_sem_p(&sem_detectLostSupRob, TM_INFINITE);
cout << "Start DetectLostSupRob" << endl << flush;
@ -825,7 +821,6 @@ void Tasks::DetectLostSupRob(void *arg){
void Tasks::AskBattery(void *arg){
while(1){
Message* p_mess_answer_battery;
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
// Synchronization barrier (waiting that all tasks are starting)
@ -834,6 +829,7 @@ void Tasks::AskBattery(void *arg){
/**************************************************************************************/
/* The task starts here */
/**************************************************************************************/
while(1){
rt_sem_p(&sem_askBattery, TM_INFINITE);
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
p_mess_answer_battery = robot.Write(robot.GetBattery());

View file

@ -66,7 +66,7 @@ private:
ComRobot robot;
int robotStarted = 0;
int move = MESSAGE_ROBOT_STOP;
bool killBattery = 0; //Used to kill the tasks start with or without watchdog
bool killBattery = 0;
bool killReceiveFromMon=0;
bool killVision=0;
bool searchArena=0;
@ -105,9 +105,12 @@ private:
RT_MUTEX mutex_drawArena;
RT_MUTEX mutex_getPosition;
RT_MUTEX mutex_killSendMon;
RT_MUTEX mutex_killStartRobWD;
RT_MUTEX mutex_killDetectLostSupRob;
RT_MUTEX mutex_killStartRob;
RT_MUTEX mutex_acquireImage;
RT_MUTEX mutex_killOpenComRobot;
/**********************************************************************/
/* Semaphores */
/**********************************************************************/