Version_officielle

This commit is contained in:
Joao Conceicao Nunes 2020-04-08 16:46:27 +02:00
parent fe6d948857
commit 5368f14d9f
3 changed files with 13 additions and 1 deletions

View file

@ -9,7 +9,7 @@
<url>tasks.cpp</url>
<bookmark id="1">
<name/>
<line>471</line>
<line>447</line>
<key/>
</bookmark>
</file>

View file

@ -76,6 +76,10 @@ void Tasks::Init() {
cerr << "Error mutex create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
if (err = rt_mutex_create(&mutex_compteurGestionCom, NULL)) {
cerr << "Error mutex create: " << strerror(-err) << endl << flush;
exit(EXIT_FAILURE);
}
cout << "Mutexes created successfully" << endl << flush;
/**************************************************************************************/
@ -364,6 +368,7 @@ void Tasks::OpenComRobot(void *arg) {
WriteInQueue(&q_messageToMon, msgSend); // msgSend will be deleted by sendToMon
}
}
/**
* @brief Thread starting the communication with the robot.
*/
@ -399,9 +404,13 @@ void Tasks::StartRobotTask(void *arg) {
if ((MessageID) cpStart == MESSAGE_ROBOT_START_WITH_WD) {
rt_sem_v(&sem_startReloadWD);
}
} else {
WriteInQueue(&q_messageToMon, new Message(MESSAGE_ANSWER_ACK));
}
}
}
/**
* @brief Thread managing the Robot's coms
*/
@ -478,7 +487,9 @@ void Tasks::MoveTask(void *arg) {
msgRcv = robot.Write(new Message((MessageID) cpMove));
rt_mutex_release(&mutex_robot);
if (msgRcv->CompareID(MESSAGE_ANSWER_ACK)) {
rt_mutex_acquire(&mutex_compteurGestionCom,TM_INFINITE);
compteur_gestionCom = 0;
rt_mutex_release (&mutex_compteurGestionCom);
} else {
compteur_gestionCom += 1;

View file

@ -91,6 +91,7 @@ private:
RT_MUTEX mutex_robot;
RT_MUTEX mutex_robotStarted;
RT_MUTEX mutex_move;
RT_MUTEX mutex_compteurGestionCom;
/**********************************************************************/
/* Semaphores */