From 5368f14d9ffb171cadb45d69dc587c4082e498e0 Mon Sep 17 00:00:00 2001 From: conceica Date: Wed, 8 Apr 2020 16:46:27 +0200 Subject: [PATCH] Version_officielle --- .../superviseur-robot/nbproject/private/private.xml | 2 +- software/raspberry/superviseur-robot/tasks.cpp | 11 +++++++++++ software/raspberry/superviseur-robot/tasks.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/software/raspberry/superviseur-robot/nbproject/private/private.xml b/software/raspberry/superviseur-robot/nbproject/private/private.xml index 87ac888..0ffd21c 100644 --- a/software/raspberry/superviseur-robot/nbproject/private/private.xml +++ b/software/raspberry/superviseur-robot/nbproject/private/private.xml @@ -9,7 +9,7 @@ tasks.cpp - 471 + 447 diff --git a/software/raspberry/superviseur-robot/tasks.cpp b/software/raspberry/superviseur-robot/tasks.cpp index ab809fe..431575a 100644 --- a/software/raspberry/superviseur-robot/tasks.cpp +++ b/software/raspberry/superviseur-robot/tasks.cpp @@ -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; diff --git a/software/raspberry/superviseur-robot/tasks.h b/software/raspberry/superviseur-robot/tasks.h index 75bbac3..10f6d3b 100644 --- a/software/raspberry/superviseur-robot/tasks.h +++ b/software/raspberry/superviseur-robot/tasks.h @@ -91,6 +91,7 @@ private: RT_MUTEX mutex_robot; RT_MUTEX mutex_robotStarted; RT_MUTEX mutex_move; + RT_MUTEX mutex_compteurGestionCom; /**********************************************************************/ /* Semaphores */