echec global

This commit is contained in:
Romain Vitrat 2020-03-26 11:03:17 +01:00
parent 23fa284ea6
commit 1161d15964
5 changed files with 29 additions and 14 deletions

View file

@ -7,7 +7,13 @@
<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">
<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/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>
</open-files>
</project-private>

View file

@ -24,8 +24,8 @@
#define PRIORITY_TMOVE 20
#define PRIORITY_TSENDTOMON 22
#define PRIORITY_TRECEIVEFROMMON 25
#define PRIORITY_TSTARTROBOTWITHOUTWATCHDOG 22
#define PRIORITY_TSTARTROBOTWITHWATCHDOG 22
#define PRIORITY_TSTARTROBOTWITHOUTWATCHDOG 19
#define PRIORITY_TSTARTROBOTWITHWATCHDOG 19
#define PRIORITY_TCAMERA 21
@ -358,7 +358,7 @@ void Tasks::StartRobotTaskWithoutWatchdog(void *arg) {
rt_sem_p(&sem_startRobotWithoutWatchdog, TM_INFINITE);
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);
killBatteryBool=0;
rt_mutex_release(&mutex_kill_battery);
@ -383,7 +383,7 @@ void Tasks::StartRobotTaskWithoutWatchdog(void *arg) {
rt_mutex_acquire(&mutex_monitor, TM_INFINITE);
monitor.Write(p_mess_answer_battery);
rt_mutex_release(&mutex_monitor);
//cout << endl << flush;
cout << endl << flush;
rt_mutex_acquire(&mutex_kill_battery, TM_INFINITE);
killBattery=killBatteryBool;
rt_mutex_release(&mutex_kill_battery);
@ -408,8 +408,9 @@ void Tasks::StartRobotTaskWithWatchdog(void *arg) {
/**************************************************************************************/
Message* p_mess_answer_battery;
Message * msgSend;
int cpt=1;
int err;
int cpt=0;
int killBattery=0;
rt_sem_p(&sem_startRobotWithWatchdog, TM_INFINITE);
cout << "Start robot with watchdog (";
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
@ -427,27 +428,34 @@ void Tasks::StartRobotTaskWithWatchdog(void *arg) {
cout << "Movement answer: " << msgSend->ToString() << endl << flush;
WriteInQueue(&q_messageToMon, msgSend); // msgSend will be deleted by sendToMon
//si réussite :
if (msgSend->GetID() == MESSAGE_ANSWER_ACK) {
rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
robotStarted = 1;
rt_mutex_release(&mutex_robotStarted);
rt_task_set_periodic(NULL, TM_NOW, 500000000);
while (1) {
while (!killBattery) {
rt_task_wait_period(NULL);
cpt++;
if(cpt%2==0){
rt_mutex_acquire(&mutex_robot, TM_INFINITE);
robot.Write(robot.ReloadWD());
rt_mutex_release(&mutex_robot);
}
rt_task_wait_period(NULL);
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;
//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);
}
}
}

View file

@ -66,7 +66,6 @@ private:
ComRobot robot;
int robotStarted = 0;
int killBatteryBool = 0;
int killRobotWithoutWd = 0;
int move = MESSAGE_ROBOT_STOP;
/**********************************************************************/

View file

@ -6,6 +6,8 @@
</data>
<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">
<group/>
<group>
<file>file:/home/romainv/Documents/temps_reel/dumber1/software/simulateur/main.cpp</file>
</group>
</open-files>
</project-private>