Fixed battery error

This commit is contained in:
Robin Marin-Muller 2024-04-04 18:13:03 +02:00
parent c67814a39b
commit 80fa2240f8
3 changed files with 11 additions and 15 deletions

View file

@ -1,4 +1,4 @@
#Thu Apr 04 17:49:31 CEST 2024 #Thu Apr 04 18:04:54 CEST 2024
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/main.cpp=c1712238648769 /home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/main.cpp=c1712238648769
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-Debug__PC_.mk=c1712238648773 /home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-Debug__PC_.mk=c1712238648773
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/private/Makefile-variables.mk=c1712238648790 /home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/private/Makefile-variables.mk=c1712238648790
@ -8,13 +8,13 @@
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-Debug__RPI_.mk=c1712238648775 /home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-Debug__RPI_.mk=c1712238648775
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/.gitignore=c1712238648721 /home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/.gitignore=c1712238648721
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Package-Debug__PC_.bash=c1712238648782 /home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Package-Debug__PC_.bash=c1712238648782
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/tasks.h=c1712244813410 /home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/tasks.h=c1712246527533
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/README.md=c1712238648637 /home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/README.md=c1712238648637
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/project.xml=c1712238648826 /home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/project.xml=c1712238648826
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-impl.mk=c1712238648778 /home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-impl.mk=c1712238648778
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/superviseur.doxygen=c1712238648829 /home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/superviseur.doxygen=c1712238648829
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/README.md=c1712238648730 /home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/base64/README.md=c1712238648730
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/tasks.cpp=c1712245729354 /home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/tasks.cpp=c1712246689680
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/comrobot.cpp=c1712238648753 /home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/comrobot.cpp=c1712238648753
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/.dep.inc=c1712238648629 /home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/.dep.inc=c1712238648629
/home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/img.h=c1712238648760 /home/marin-muller/Documents/4A/Robot/dumber/software/raspberry/superviseur-robot/lib/img.h=c1712238648760

View file

@ -487,13 +487,6 @@ Message *Tasks::ReadInQueue(RT_QUEUE *queue) {
/* OUR CODE */ /* OUR CODE */
void Tasks::SendToRobot(MessageID message)
{
rt_mutex_acquire(&mutex_monitor, TM_INFINITE);
WriteInQueue(&q_messageToMon, new Message(message));
rt_mutex_release(&mutex_monitor);
}
void Tasks::BatteryStatusTask(void * arg) { void Tasks::BatteryStatusTask(void * arg) {
// Variables // Variables
int rs(0); int rs(0);
@ -519,7 +512,10 @@ void Tasks::BatteryStatusTask(void * arg) {
getbatterytask = robotBatteryGet; getbatterytask = robotBatteryGet;
if ((rs != 0) && getbatterytask) { if ((rs != 0) && getbatterytask) {
SendToRobot(MESSAGE_ROBOT_BATTERY_GET); rt_mutex_acquire(&mutex_robot, TM_INFINITE);
Message* msg = robot.Write(new Message(MESSAGE_ROBOT_BATTERY_GET));
rt_mutex_release(&mutex_robot);
WriteInQueue(&q_messageToMon, msg);
robotBatteryGet = false; robotBatteryGet = false;
getbatterytask = false; getbatterytask = false;
} }
@ -563,10 +559,10 @@ void Tasks::OpenCamera(void * arg)
if(is_opened) if(is_opened)
{ {
cameraStatus = CameraStatusEnum::OPENED; cameraStatus = CameraStatusEnum::OPENED;
SendToRobot(MESSAGE_ANSWER_ACK); WriteInQueue(&q_messageToMon, new Message(MESSAGE_ANSWER_ACK));
} }
else { else {
SendToRobot(MESSAGE_ANSWER_NACK); WriteInQueue(&q_messageToMon, new Message(MESSAGE_ANSWER_NACK));
} }
rt_mutex_release(&mutex_cameraStatus); rt_mutex_release(&mutex_cameraStatus);
} }
@ -630,7 +626,7 @@ void Tasks::CloseCamera(void * arg)
rt_mutex_acquire(&mutex_cameraStatus, TM_INFINITE); rt_mutex_acquire(&mutex_cameraStatus, TM_INFINITE);
cameraStatus = CameraStatusEnum::CLOSED; cameraStatus = CameraStatusEnum::CLOSED;
rt_mutex_release(&mutex_cameraStatus); rt_mutex_release(&mutex_cameraStatus);
SendToRobot(MESSAGE_ANSWER_ACK); WriteInQueue(&q_messageToMon, new Message(MESSAGE_ANSWER_ACK));
} }
} }
} }

View file

@ -158,7 +158,7 @@ private:
void CloseCamera(void * arg); void CloseCamera(void * arg);
// Utility functions // Utility functions
void SendToRobot(MessageID message);
/**********************************************************************/ /**********************************************************************/