Browse Source

Definition des threads, des mutex, semaphores et messagequeue

Nabil Moukhlis 10 months ago
parent
commit
f76171f0b3

+ 16
- 2
software/raspberry/superviseur-robot/tasks.cpp View File

@@ -28,6 +28,8 @@
28 28
 #define PRIORITY_TCAMERA 21
29 29
 #define PRIORITY_TBATTERY 31
30 30
 
31
+
32
+
31 33
 /*
32 34
  * Some remarks:
33 35
  * 1- This program is mostly a template. It shows you how to create tasks, semaphore
@@ -137,8 +139,21 @@ void Tasks::Init() {
137 139
         cerr << "Error msg queue create: " << strerror(-err) << endl << flush;
138 140
         exit(EXIT_FAILURE);
139 141
     }
142
+    if ((err = rt_queue_create(&q_messageComRobot, "q_messageComRobot", sizeof (Message*)*50, Q_UNLIMITED, Q_FIFO)) < 0) {
143
+        cerr << "Error messageComRobot queue create: " << strerror(-err) << endl << flush;
144
+        exit(EXIT_FAILURE);
145
+    }
146
+    
147
+    if ((err = rt_queue_create(&q_messageControlRobot, "q_messageControlRobot", sizeof (Message*)*50, Q_UNLIMITED, Q_FIFO)) < 0) {
148
+        cerr << "Error messageControlRobot queue create: " << strerror(-err) << endl << flush;
149
+        exit(EXIT_FAILURE);
150
+    }
151
+    
152
+    if ((err = rt_queue_create(&q_messageControlCam, "q_messageControlCam", sizeof (Message*)*50, Q_UNLIMITED, Q_FIFO)) < 0) {
153
+        cerr << "Error messageControlCam queue create: " << strerror(-err) << endl << flush;
154
+        exit(EXIT_FAILURE);
155
+    } 
140 156
     cout << "Queues created successfully" << endl << flush;
141
-
142 157
 }
143 158
 
144 159
 /**
@@ -455,7 +470,6 @@ void Tasks::ReadBattery(void *arg){
455 470
                 monitor.Write(msg);
456 471
                 rt_mutex_release(&mutex_monitor);
457 472
             }
458
-             
459 473
         }
460 474
        
461 475
         cout << endl << flush;

+ 13
- 1
software/raspberry/superviseur-robot/tasks.h View File

@@ -77,6 +77,9 @@ private:
77 77
     RT_TASK th_startRobot;
78 78
     RT_TASK th_move;
79 79
     RT_TASK th_getBattery;
80
+    RT_TASK th_watchDog;
81
+    RT_TASK th_controlCamera;
82
+    RT_TASK th_picture;
80 83
     
81 84
     /**********************************************************************/
82 85
     /* Mutex                                                              */
@@ -85,7 +88,10 @@ private:
85 88
     RT_MUTEX mutex_robot;
86 89
     RT_MUTEX mutex_robotStarted;
87 90
     RT_MUTEX mutex_move;
88
-
91
+    
92
+    RT_MUTEX mutex_camera;
93
+    RT_MUTEX mutex_controlStruct;
94
+    
89 95
     /**********************************************************************/
90 96
     /* Semaphores                                                         */
91 97
     /**********************************************************************/
@@ -93,6 +99,8 @@ private:
93 99
     RT_SEM sem_openComRobot;
94 100
     RT_SEM sem_serverOk;
95 101
     RT_SEM sem_startRobot;
102
+    
103
+    
96 104
 
97 105
     /**********************************************************************/
98 106
     /* Message queues                                                     */
@@ -100,6 +108,10 @@ private:
100 108
     int MSG_QUEUE_SIZE;
101 109
     RT_QUEUE q_messageToMon;
102 110
     
111
+    RT_QUEUE q_messageComRobot;
112
+    RT_QUEUE q_messageControlRobot;
113
+    RT_QUEUE q_messageControlCam;
114
+    
103 115
     /**********************************************************************/
104 116
     /* Tasks' functions                                                   */
105 117
     /**********************************************************************/

Loading…
Cancel
Save