echec global
This commit is contained in:
parent
23fa284ea6
commit
1161d15964
5 changed files with 29 additions and 14 deletions
|
@ -135,7 +135,7 @@ int ComMonitor::AcceptClient() {
|
||||||
* Send a message to monitor
|
* Send a message to monitor
|
||||||
*
|
*
|
||||||
* @param msg Message to send to monitor
|
* @param msg Message to send to monitor
|
||||||
* @attention Message given in parameter will be destroyed (delete) after being sent. No need for user to delete message after that.
|
* @attention Message given in parameter will be destroyed (delete) after being sent. No need for user to delete message after that.
|
||||||
* @warning Write is not thread safe : check that multiple tasks can't access this method simultaneously
|
* @warning Write is not thread safe : check that multiple tasks can't access this method simultaneously
|
||||||
*/
|
*/
|
||||||
void ComMonitor::Write(Message *msg) {
|
void ComMonitor::Write(Message *msg) {
|
||||||
|
|
|
@ -7,7 +7,13 @@
|
||||||
<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/romainv/Documents/temps_reel/dumber1/software/raspberry/superviseur-robot/lib/camera.cpp</file>
|
||||||
|
<file>file:/home/romainv/Documents/temps_reel/dumber1/software/raspberry/superviseur-robot/lib/comrobot.cpp</file>
|
||||||
<file>file:/home/romainv/Documents/temps_reel/dumber1/software/raspberry/superviseur-robot/tasks.h</file>
|
<file>file:/home/romainv/Documents/temps_reel/dumber1/software/raspberry/superviseur-robot/tasks.h</file>
|
||||||
|
<file>file:/home/romainv/Documents/temps_reel/dumber1/software/raspberry/superviseur-robot/lib/img.cpp</file>
|
||||||
|
<file>file:/home/romainv/Documents/temps_reel/dumber1/software/raspberry/superviseur-robot/lib/img.h</file>
|
||||||
|
<file>file:/home/romainv/Documents/temps_reel/dumber1/software/raspberry/superviseur-robot/tasks.cpp</file>
|
||||||
|
<file>file:/home/romainv/Documents/temps_reel/dumber1/software/raspberry/superviseur-robot/lib/commonitor.cpp</file>
|
||||||
</group>
|
</group>
|
||||||
</open-files>
|
</open-files>
|
||||||
</project-private>
|
</project-private>
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
#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 22
|
#define PRIORITY_TSTARTROBOTWITHOUTWATCHDOG 19
|
||||||
#define PRIORITY_TSTARTROBOTWITHWATCHDOG 22
|
#define PRIORITY_TSTARTROBOTWITHWATCHDOG 19
|
||||||
#define PRIORITY_TCAMERA 21
|
#define PRIORITY_TCAMERA 21
|
||||||
|
|
||||||
|
|
||||||
|
@ -358,7 +358,7 @@ void Tasks::StartRobotTaskWithoutWatchdog(void *arg) {
|
||||||
rt_sem_p(&sem_startRobotWithoutWatchdog, TM_INFINITE);
|
rt_sem_p(&sem_startRobotWithoutWatchdog, TM_INFINITE);
|
||||||
cout << "Start robot without watchdog (";
|
cout << "Start robot without watchdog (";
|
||||||
|
|
||||||
//Boolean to get the battery
|
//Boolean to kill the loop and stop the robot and battery acquisition
|
||||||
rt_mutex_acquire(&mutex_kill_battery, TM_INFINITE);
|
rt_mutex_acquire(&mutex_kill_battery, TM_INFINITE);
|
||||||
killBatteryBool=0;
|
killBatteryBool=0;
|
||||||
rt_mutex_release(&mutex_kill_battery);
|
rt_mutex_release(&mutex_kill_battery);
|
||||||
|
@ -383,7 +383,7 @@ void Tasks::StartRobotTaskWithoutWatchdog(void *arg) {
|
||||||
rt_mutex_acquire(&mutex_monitor, TM_INFINITE);
|
rt_mutex_acquire(&mutex_monitor, TM_INFINITE);
|
||||||
monitor.Write(p_mess_answer_battery);
|
monitor.Write(p_mess_answer_battery);
|
||||||
rt_mutex_release(&mutex_monitor);
|
rt_mutex_release(&mutex_monitor);
|
||||||
//cout << endl << flush;
|
cout << endl << flush;
|
||||||
rt_mutex_acquire(&mutex_kill_battery, TM_INFINITE);
|
rt_mutex_acquire(&mutex_kill_battery, TM_INFINITE);
|
||||||
killBattery=killBatteryBool;
|
killBattery=killBatteryBool;
|
||||||
rt_mutex_release(&mutex_kill_battery);
|
rt_mutex_release(&mutex_kill_battery);
|
||||||
|
@ -408,8 +408,9 @@ void Tasks::StartRobotTaskWithWatchdog(void *arg) {
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
Message* p_mess_answer_battery;
|
Message* p_mess_answer_battery;
|
||||||
Message * msgSend;
|
Message * msgSend;
|
||||||
int cpt=1;
|
int cpt=0;
|
||||||
int err;
|
int killBattery=0;
|
||||||
|
|
||||||
rt_sem_p(&sem_startRobotWithWatchdog, TM_INFINITE);
|
rt_sem_p(&sem_startRobotWithWatchdog, TM_INFINITE);
|
||||||
cout << "Start robot with watchdog (";
|
cout << "Start robot with watchdog (";
|
||||||
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
|
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
|
||||||
|
@ -423,31 +424,38 @@ void Tasks::StartRobotTaskWithWatchdog(void *arg) {
|
||||||
|
|
||||||
cout << msgSend->GetID();
|
cout << msgSend->GetID();
|
||||||
cout << ")" << endl;
|
cout << ")" << endl;
|
||||||
|
|
||||||
cout << "Movement answer: " << msgSend->ToString() << endl << flush;
|
cout << "Movement answer: " << msgSend->ToString() << endl << flush;
|
||||||
WriteInQueue(&q_messageToMon, msgSend); // msgSend will be deleted by sendToMon
|
WriteInQueue(&q_messageToMon, msgSend); // msgSend will be deleted by sendToMon
|
||||||
|
|
||||||
|
//si réussite :
|
||||||
if (msgSend->GetID() == MESSAGE_ANSWER_ACK) {
|
if (msgSend->GetID() == MESSAGE_ANSWER_ACK) {
|
||||||
|
|
||||||
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, 500000000);
|
rt_task_set_periodic(NULL, TM_NOW, 500000000);
|
||||||
while (1) {
|
while (!killBattery) {
|
||||||
|
rt_task_wait_period(NULL);
|
||||||
cpt++;
|
cpt++;
|
||||||
if(cpt%2==0){
|
if(cpt%2==0){
|
||||||
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
|
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
|
||||||
robot.Write(robot.ReloadWD());
|
robot.Write(robot.ReloadWD());
|
||||||
rt_mutex_release(&mutex_robot);
|
rt_mutex_release(&mutex_robot);
|
||||||
}
|
}
|
||||||
rt_task_wait_period(NULL);
|
|
||||||
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());
|
||||||
rt_mutex_release(&mutex_robot);
|
rt_mutex_release(&mutex_robot);
|
||||||
|
|
||||||
rt_mutex_acquire(&mutex_monitor, TM_INFINITE);
|
rt_mutex_acquire(&mutex_monitor, TM_INFINITE);
|
||||||
monitor.Write(p_mess_answer_battery);
|
monitor.Write(p_mess_answer_battery);
|
||||||
rt_mutex_release(&mutex_monitor);
|
rt_mutex_release(&mutex_monitor);
|
||||||
cout << endl << flush;
|
cout << endl << flush;
|
||||||
|
|
||||||
|
//mise à jour de la variable d'acquisition de la batterie
|
||||||
|
rt_mutex_acquire(&mutex_kill_battery, TM_INFINITE);
|
||||||
|
killBattery=killBatteryBool;
|
||||||
|
rt_mutex_release(&mutex_kill_battery);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,6 @@ private:
|
||||||
ComRobot robot;
|
ComRobot robot;
|
||||||
int robotStarted = 0;
|
int robotStarted = 0;
|
||||||
int killBatteryBool = 0;
|
int killBatteryBool = 0;
|
||||||
int killRobotWithoutWd = 0;
|
|
||||||
int move = MESSAGE_ROBOT_STOP;
|
int move = MESSAGE_ROBOT_STOP;
|
||||||
|
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
</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/romainv/Documents/temps_reel/dumber1/software/simulateur/main.cpp</file>
|
||||||
|
</group>
|
||||||
</open-files>
|
</open-files>
|
||||||
</project-private>
|
</project-private>
|
||||||
|
|
Loading…
Reference in a new issue