Compare commits

..

2 commits

Author SHA1 Message Date
2deabff76f Modif comments Raph 2 + while sem_barrier 2020-04-03 16:22:52 +02:00
54c744b28b Modified comments on master Raph 2020-04-03 15:48:21 +02:00
2 changed files with 22 additions and 21 deletions

View file

@ -138,6 +138,7 @@ 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);
@ -555,6 +556,7 @@ 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);
@ -562,7 +564,6 @@ 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);
@ -644,7 +645,7 @@ void Tasks::StartRobotTaskWithoutWatchdog(void *arg) {
*/
void Tasks::StartRobotTaskWithWatchdog(void *arg) {
int killBatteryOk;
int killBatteryOk=0;
int cpt=1;
Message * msgSend;
@ -659,7 +660,6 @@ 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,6 +710,9 @@ 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);
@ -717,9 +720,6 @@ 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,6 +752,10 @@ 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;
@ -821,6 +825,7 @@ 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)
@ -829,7 +834,6 @@ 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;
bool killBattery = 0; //Used to kill the tasks start with or without watchdog
bool killReceiveFromMon=0;
bool killVision=0;
bool searchArena=0;
@ -105,12 +105,9 @@ 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 */
/**********************************************************************/