suppression fonction batterie et chgt priorités startrobot
This commit is contained in:
parent
f65b413a40
commit
cb30b572c7
3 changed files with 27 additions and 55 deletions
|
@ -24,10 +24,9 @@
|
||||||
#define PRIORITY_TMOVE 20
|
#define PRIORITY_TMOVE 20
|
||||||
#define PRIORITY_TSENDTOMON 22
|
#define PRIORITY_TSENDTOMON 22
|
||||||
#define PRIORITY_TRECEIVEFROMMON 25
|
#define PRIORITY_TRECEIVEFROMMON 25
|
||||||
#define PRIORITY_TSTARTROBOTWITHOUTWATCHDOG 20
|
#define PRIORITY_TSTARTROBOTWITHOUTWATCHDOG 22
|
||||||
#define PRIORITY_TSTARTROBOTWITHWATCHDOG 20
|
#define PRIORITY_TSTARTROBOTWITHWATCHDOG 22
|
||||||
#define PRIORITY_TCAMERA 21
|
#define PRIORITY_TCAMERA 21
|
||||||
#define PRIORITY_TBATTERY 31
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -104,10 +103,6 @@ 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_askBattery, NULL, 0, S_FIFO)) {
|
|
||||||
cerr << "Error semaphore create: " << strerror(-err) << endl << flush;
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
cout << "Semaphores created successfully" << endl << flush;
|
cout << "Semaphores created successfully" << endl << flush;
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
@ -141,10 +136,7 @@ void Tasks::Init() {
|
||||||
cerr << "Error task create: " << strerror(-err) << endl << flush;
|
cerr << "Error task create: " << strerror(-err) << endl << flush;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (err = rt_task_create(&th_askBattery, "th_askBattery", 0, PRIORITY_TBATTERY, 0)) {
|
|
||||||
cerr << "Error task create: " << strerror(-err) << endl << flush;
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
cout << "Tasks created successfully" << endl << flush;
|
cout << "Tasks created successfully" << endl << flush;
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
@ -193,10 +185,6 @@ void Tasks::Run() {
|
||||||
cerr << "Error task start: " << strerror(-err) << endl << flush;
|
cerr << "Error task start: " << strerror(-err) << endl << flush;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (err = rt_task_start(&th_askBattery, (void(*)(void*)) & Tasks::Ask_Battery, this)) {
|
|
||||||
cerr << "Error battery start: " << strerror(-err) << endl << flush;
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
cout << "Tasks launched" << endl << flush;
|
cout << "Tasks launched" << endl << flush;
|
||||||
}
|
}
|
||||||
|
@ -291,7 +279,8 @@ void Tasks::ReceiveFromMonTask(void *arg) {
|
||||||
|
|
||||||
if (msgRcv->CompareID(MESSAGE_MONITOR_LOST)) {
|
if (msgRcv->CompareID(MESSAGE_MONITOR_LOST)) {
|
||||||
delete(msgRcv);
|
delete(msgRcv);
|
||||||
exit(-1);
|
//exit(-1);
|
||||||
|
|
||||||
} else if (msgRcv->CompareID(MESSAGE_ROBOT_COM_OPEN)) {
|
} else if (msgRcv->CompareID(MESSAGE_ROBOT_COM_OPEN)) {
|
||||||
rt_sem_v(&sem_openComRobot);
|
rt_sem_v(&sem_openComRobot);
|
||||||
} else if (msgRcv->CompareID(MESSAGE_ROBOT_START_WITHOUT_WD)) {
|
} else if (msgRcv->CompareID(MESSAGE_ROBOT_START_WITHOUT_WD)) {
|
||||||
|
@ -360,7 +349,7 @@ void Tasks::StartRobotTaskWithoutWatchdog(void *arg) {
|
||||||
/* The task startRobot starts here */
|
/* The task startRobot starts here */
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
while (1) {
|
while (1) {
|
||||||
int err;
|
Message* p_mess_answer_battery;
|
||||||
Message * msgSend;
|
Message * msgSend;
|
||||||
rt_sem_p(&sem_startRobotWithoutWatchdog, TM_INFINITE);
|
rt_sem_p(&sem_startRobotWithoutWatchdog, TM_INFINITE);
|
||||||
cout << "Start robot without watchdog (";
|
cout << "Start robot without watchdog (";
|
||||||
|
@ -377,11 +366,16 @@ void Tasks::StartRobotTaskWithoutWatchdog(void *arg) {
|
||||||
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
|
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
|
||||||
robotStarted = 1;
|
robotStarted = 1;
|
||||||
rt_mutex_release(&mutex_robotStarted);
|
rt_mutex_release(&mutex_robotStarted);
|
||||||
rt_task_set_periodic(NULL, TM_NOW, 5000000000);
|
rt_task_set_periodic(NULL, TM_NOW, 3000000000);
|
||||||
while (1) {
|
while (1) {
|
||||||
rt_task_wait_period(NULL);
|
rt_task_wait_period(NULL);
|
||||||
rt_sem_v(&sem_askBattery);
|
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
|
||||||
|
p_mess_answer_battery = robot.Write(robot.GetBattery());
|
||||||
|
rt_mutex_release(&mutex_robot);
|
||||||
|
rt_mutex_acquire(&mutex_monitor, TM_INFINITE);
|
||||||
|
monitor.Write(p_mess_answer_battery);
|
||||||
|
rt_mutex_release(&mutex_monitor);
|
||||||
|
cout << endl << flush;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -403,6 +397,7 @@ void Tasks::StartRobotTaskWithWatchdog(void *arg) {
|
||||||
/* The task startRobot starts here */
|
/* The task startRobot starts here */
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
while (1) {
|
while (1) {
|
||||||
|
Message* p_mess_answer_battery;
|
||||||
Message * msgSend;
|
Message * msgSend;
|
||||||
int cpt=1;
|
int cpt=1;
|
||||||
int err;
|
int err;
|
||||||
|
@ -422,13 +417,21 @@ void Tasks::StartRobotTaskWithWatchdog(void *arg) {
|
||||||
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
|
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
|
||||||
robotStarted = 1;
|
robotStarted = 1;
|
||||||
rt_mutex_release(&mutex_robotStarted);
|
rt_mutex_release(&mutex_robotStarted);
|
||||||
rt_task_set_periodic(NULL, TM_NOW, 5000000000);
|
rt_task_set_periodic(NULL, TM_NOW, 300000000);
|
||||||
while (1) {
|
while (1) {
|
||||||
cpt++;
|
cpt++;
|
||||||
rt_task_wait_period(NULL);
|
rt_task_wait_period(NULL);
|
||||||
|
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
|
||||||
robot.Write(robot.ReloadWD());
|
robot.Write(robot.ReloadWD());
|
||||||
|
rt_mutex_release(&mutex_robot);
|
||||||
if(cpt%10==0){
|
if(cpt%10==0){
|
||||||
rt_sem_v(&sem_askBattery);
|
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
|
||||||
|
p_mess_answer_battery = robot.Write(robot.GetBattery());
|
||||||
|
rt_mutex_release(&mutex_robot);
|
||||||
|
rt_mutex_acquire(&mutex_monitor, TM_INFINITE);
|
||||||
|
monitor.Write(p_mess_answer_battery);
|
||||||
|
rt_mutex_release(&mutex_monitor);
|
||||||
|
cout << endl << flush;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -476,29 +479,6 @@ void Tasks::MoveTask(void *arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Tasks::Ask_Battery(void *arg){
|
|
||||||
Message* p_mess_answer_battery;
|
|
||||||
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 */
|
|
||||||
/**************************************************************************************/
|
|
||||||
while(1){
|
|
||||||
rt_sem_p(&sem_askBattery, TM_INFINITE);
|
|
||||||
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
|
|
||||||
p_mess_answer_battery = robot.Write(robot.GetBattery());
|
|
||||||
rt_mutex_release(&mutex_robot);
|
|
||||||
rt_mutex_acquire(&mutex_monitor, TM_INFINITE);
|
|
||||||
monitor.Write(p_mess_answer_battery);
|
|
||||||
rt_mutex_release(&mutex_monitor);
|
|
||||||
cout << endl << flush;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a message in a given queue
|
* Write a message in a given queue
|
||||||
* @param queue Queue identifier
|
* @param queue Queue identifier
|
||||||
|
|
|
@ -77,7 +77,6 @@ private:
|
||||||
RT_TASK th_startRobotWithoutWatchdog;
|
RT_TASK th_startRobotWithoutWatchdog;
|
||||||
RT_TASK th_startRobotWithWatchdog;
|
RT_TASK th_startRobotWithWatchdog;
|
||||||
RT_TASK th_move;
|
RT_TASK th_move;
|
||||||
RT_TASK th_askBattery;
|
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
/* Mutex */
|
/* Mutex */
|
||||||
|
@ -86,7 +85,6 @@ private:
|
||||||
RT_MUTEX mutex_robot;
|
RT_MUTEX mutex_robot;
|
||||||
RT_MUTEX mutex_robotStarted;
|
RT_MUTEX mutex_robotStarted;
|
||||||
RT_MUTEX mutex_move;
|
RT_MUTEX mutex_move;
|
||||||
RT_MUTEX mutex_askBattery;
|
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
/* Semaphores */
|
/* Semaphores */
|
||||||
|
@ -96,7 +94,6 @@ private:
|
||||||
RT_SEM sem_serverOk;
|
RT_SEM sem_serverOk;
|
||||||
RT_SEM sem_startRobotWithoutWatchdog;
|
RT_SEM sem_startRobotWithoutWatchdog;
|
||||||
RT_SEM sem_startRobotWithWatchdog;
|
RT_SEM sem_startRobotWithWatchdog;
|
||||||
RT_SEM sem_askBattery;
|
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
/* Message queues */
|
/* Message queues */
|
||||||
|
@ -144,9 +141,6 @@ private:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Ask_Battery(void *arg);
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
/* Queue services */
|
/* Queue services */
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
</data>
|
</data>
|
||||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||||
<group>
|
<group/>
|
||||||
<file>file:/home/etud/dumber/software/simulateur/main.cpp</file>
|
|
||||||
</group>
|
|
||||||
</open-files>
|
</open-files>
|
||||||
</project-private>
|
</project-private>
|
||||||
|
|
Loading…
Reference in a new issue