Compare commits
2 commits
251b123a6b
...
2deabff76f
Author | SHA1 | Date | |
---|---|---|---|
2deabff76f | |||
54c744b28b |
2 changed files with 21 additions and 19 deletions
|
@ -138,6 +138,7 @@ void Tasks::Init() {
|
||||||
cerr << "Error semaphore create: " << strerror(-err) << endl << flush;
|
cerr << "Error semaphore create: " << strerror(-err) << endl << flush;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err = rt_sem_create(&sem_startRobotWithoutWatchdog, NULL, 0, S_FIFO)) {
|
if (err = rt_sem_create(&sem_startRobotWithoutWatchdog, NULL, 0, S_FIFO)) {
|
||||||
cerr << "Error semaphore create: " << strerror(-err) << endl << flush;
|
cerr << "Error semaphore create: " << strerror(-err) << endl << flush;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -555,14 +556,14 @@ void Tasks::OpenComRobot(void *arg) { //PAS DE SOUCIS AU REDEMARAGE
|
||||||
int err;
|
int err;
|
||||||
//bool killOpenComRobotOk = 0;
|
//bool killOpenComRobotOk = 0;
|
||||||
|
|
||||||
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
while (1) { //Is used to restart process
|
||||||
// Synchronization barrier (waiting that all tasks are starting)
|
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
||||||
rt_sem_p(&sem_barrier, TM_INFINITE);
|
// Synchronization barrier (waiting that all tasks are starting)
|
||||||
|
rt_sem_p(&sem_barrier, TM_INFINITE);
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
/* The task openComRobot starts here */
|
/* The task openComRobot starts here */
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
while (1) { //Is used to restart process
|
|
||||||
rt_sem_p(&sem_openComRobot, TM_INFINITE);
|
rt_sem_p(&sem_openComRobot, TM_INFINITE);
|
||||||
cout << "Open serial com (";
|
cout << "Open serial com (";
|
||||||
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
|
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
|
||||||
|
@ -709,16 +710,16 @@ void Tasks::MoveTask(void *arg) {
|
||||||
int rs;
|
int rs;
|
||||||
int cpMove;
|
int cpMove;
|
||||||
|
|
||||||
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
rt_task_set_periodic(NULL, TM_NOW, 100000000);
|
||||||
// Synchronization barrier (waiting that all tasks are starting)
|
|
||||||
rt_sem_p(&sem_barrier, TM_INFINITE);
|
while (1) {
|
||||||
|
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
||||||
|
// Synchronization barrier (waiting that all tasks are starting)
|
||||||
|
rt_sem_p(&sem_barrier, TM_INFINITE);
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
/* The task starts here */
|
/* The task starts here */
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
rt_task_set_periodic(NULL, TM_NOW, 100000000);
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
rt_task_wait_period(NULL);
|
rt_task_wait_period(NULL);
|
||||||
cout << "Periodic movement update";
|
cout << "Periodic movement update";
|
||||||
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
|
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
|
||||||
|
@ -751,6 +752,10 @@ void Tasks::DetectLostSupRob(void *arg){
|
||||||
|
|
||||||
while(1){//Used to restart process
|
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
|
//Wait the Communication with the Robot to be Set
|
||||||
rt_sem_p(&sem_detectLostSupRob, TM_INFINITE);
|
rt_sem_p(&sem_detectLostSupRob, TM_INFINITE);
|
||||||
cout << "Start DetectLostSupRob" << endl << flush;
|
cout << "Start DetectLostSupRob" << endl << flush;
|
||||||
|
@ -820,15 +825,15 @@ void Tasks::DetectLostSupRob(void *arg){
|
||||||
|
|
||||||
|
|
||||||
void Tasks::AskBattery(void *arg){
|
void Tasks::AskBattery(void *arg){
|
||||||
Message* p_mess_answer_battery;
|
while(1){
|
||||||
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
Message* p_mess_answer_battery;
|
||||||
// Synchronization barrier (waiting that all tasks are starting)
|
cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
|
||||||
rt_sem_p(&sem_barrier, TM_INFINITE);
|
// Synchronization barrier (waiting that all tasks are starting)
|
||||||
|
rt_sem_p(&sem_barrier, TM_INFINITE);
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
/* The task starts here */
|
/* The task starts here */
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
while(1){
|
|
||||||
rt_sem_p(&sem_askBattery, TM_INFINITE);
|
rt_sem_p(&sem_askBattery, TM_INFINITE);
|
||||||
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
|
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
|
||||||
p_mess_answer_battery = robot.Write(robot.GetBattery());
|
p_mess_answer_battery = robot.Write(robot.GetBattery());
|
||||||
|
|
|
@ -66,7 +66,7 @@ private:
|
||||||
ComRobot robot;
|
ComRobot robot;
|
||||||
int robotStarted = 0;
|
int robotStarted = 0;
|
||||||
int move = MESSAGE_ROBOT_STOP;
|
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 killReceiveFromMon=0;
|
||||||
bool killVision=0;
|
bool killVision=0;
|
||||||
bool searchArena=0;
|
bool searchArena=0;
|
||||||
|
@ -105,12 +105,9 @@ private:
|
||||||
RT_MUTEX mutex_drawArena;
|
RT_MUTEX mutex_drawArena;
|
||||||
RT_MUTEX mutex_getPosition;
|
RT_MUTEX mutex_getPosition;
|
||||||
RT_MUTEX mutex_killSendMon;
|
RT_MUTEX mutex_killSendMon;
|
||||||
RT_MUTEX mutex_killStartRobWD;
|
|
||||||
RT_MUTEX mutex_killDetectLostSupRob;
|
RT_MUTEX mutex_killDetectLostSupRob;
|
||||||
RT_MUTEX mutex_killStartRob;
|
RT_MUTEX mutex_killStartRob;
|
||||||
RT_MUTEX mutex_acquireImage;
|
RT_MUTEX mutex_acquireImage;
|
||||||
|
|
||||||
RT_MUTEX mutex_killOpenComRobot;
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
/* Semaphores */
|
/* Semaphores */
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
Loading…
Reference in a new issue