Browse Source

Terminé le projet de base (sans cam)

Tali Elies 10 months ago
parent
commit
d86f0fca25

+ 1
- 1
software/raspberry/superviseur-robot/nbproject/Makefile-Debug__RPI_.mk View File

@@ -21,7 +21,7 @@ FC=gfortran
21 21
 AS=as
22 22
 
23 23
 # Macros
24
-CND_PLATFORM=GNU-None
24
+CND_PLATFORM=GNU-Linux
25 25
 CND_DLIB_EXT=so
26 26
 CND_CONF=Debug__RPI_
27 27
 CND_DISTDIR=dist

+ 5
- 5
software/raspberry/superviseur-robot/nbproject/Makefile-variables.mk View File

@@ -15,13 +15,13 @@ CND_PACKAGE_DIR_Debug__PC_=dist/Debug__PC_/GNU-Linux/package
15 15
 CND_PACKAGE_NAME_Debug__PC_=superviseur-robot.tar
16 16
 CND_PACKAGE_PATH_Debug__PC_=dist/Debug__PC_/GNU-Linux/package/superviseur-robot.tar
17 17
 # Debug__RPI_ configuration
18
-CND_PLATFORM_Debug__RPI_=GNU-None
19
-CND_ARTIFACT_DIR_Debug__RPI_=dist/Debug__RPI_/GNU-None
18
+CND_PLATFORM_Debug__RPI_=GNU-Linux
19
+CND_ARTIFACT_DIR_Debug__RPI_=dist/Debug__RPI_/GNU-Linux
20 20
 CND_ARTIFACT_NAME_Debug__RPI_=superviseur-robot
21
-CND_ARTIFACT_PATH_Debug__RPI_=dist/Debug__RPI_/GNU-None/superviseur-robot
22
-CND_PACKAGE_DIR_Debug__RPI_=dist/Debug__RPI_/GNU-None/package
21
+CND_ARTIFACT_PATH_Debug__RPI_=dist/Debug__RPI_/GNU-Linux/superviseur-robot
22
+CND_PACKAGE_DIR_Debug__RPI_=dist/Debug__RPI_/GNU-Linux/package
23 23
 CND_PACKAGE_NAME_Debug__RPI_=superviseur-robot.tar
24
-CND_PACKAGE_PATH_Debug__RPI_=dist/Debug__RPI_/GNU-None/package/superviseur-robot.tar
24
+CND_PACKAGE_PATH_Debug__RPI_=dist/Debug__RPI_/GNU-Linux/package/superviseur-robot.tar
25 25
 #
26 26
 # include compiler specific variables
27 27
 #

+ 1
- 1
software/raspberry/superviseur-robot/nbproject/Package-Debug__RPI_.bash View File

@@ -6,7 +6,7 @@
6 6
 
7 7
 # Macros
8 8
 TOP=`pwd`
9
-CND_PLATFORM=GNU-None
9
+CND_PLATFORM=GNU-Linux
10 10
 CND_CONF=Debug__RPI_
11 11
 CND_DISTDIR=dist
12 12
 CND_BUILDDIR=build

+ 2
- 2
software/raspberry/superviseur-robot/nbproject/private/configurations.xml View File

@@ -41,8 +41,8 @@
41 41
     </conf>
42 42
     <conf name="Debug__RPI_" type="1">
43 43
       <toolsSet>
44
-        <developmentServer>pi@10.105.1.01:22</developmentServer>
45
-        <platform>6</platform>
44
+        <developmentServer>pi@10.105.1.11:22</developmentServer>
45
+        <platform>2</platform>
46 46
       </toolsSet>
47 47
       <dbx_gdbdebugger version="1">
48 48
         <gdb_pathmaps>

+ 0
- 0
software/raspberry/superviseur-robot/nbproject/private/downloads-10.105.1.11-pi-22 View File


+ 2
- 1
software/raspberry/superviseur-robot/nbproject/private/private.xml View File

@@ -11,8 +11,9 @@
11 11
             <file>file:/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/main.cpp</file>
12 12
             <file>file:/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/tasks.cpp</file>
13 13
             <file>file:/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/tasks.h</file>
14
+            <file>file:/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/img.cpp</file>
14 15
             <file>file:/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/comrobot.h</file>
15
-            <file>file:/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/messages.cpp</file>
16
+            <file>file:/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/img.h</file>
16 17
             <file>file:/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/commonitor.cpp</file>
17 18
         </group>
18 19
     </open-files>

+ 39
- 0
software/raspberry/superviseur-robot/nbproject/private/timestamps-10.105.1.11-pi-22 View File

@@ -0,0 +1,39 @@
1
+#Mon Mar 15 11:43:08 CET 2021
2
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/scriptRasp.sh=c1614326506000
3
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/camera.cpp=c1614324985000
4
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/img.cpp=c1614324985000
5
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/comrobot.cpp=c1614324985000
6
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/base64/test.cpp=c1614324985000
7
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/nbproject/project.xml=c1614324985000
8
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/commonitor.cpp=c1614324985000
9
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/base64/base64.h=c1614324985000
10
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/base64/LICENSE=c1614324985000
11
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/nbproject/project.properties=c1614324985000
12
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/tasks.h=c1615800561000
13
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/img.h=c1614324985000
14
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/messages.h=c1614324985000
15
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/tasks.cpp=c1615804981000
16
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-impl.mk=c1614324985000
17
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/.gitignore=c1614324985000
18
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/nbproject/Package-Debug__PC_.bash=c1614324985000
19
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/gdbsudo.sh=c1614324985000
20
+VERSION=1.3
21
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/commonitor.h=c1614324985000
22
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/README.md=c1614324985000
23
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/base64/README.md=c1614324985000
24
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/.dep.inc=c1614324985000
25
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/comrobot.h=c1614324985000
26
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/base64/.gitignore=c1614324985000
27
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/nbproject/private/Makefile-variables.mk=c1614324985000
28
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/nbproject/Package-Debug__RPI_.bash=c1615797916000
29
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/Makefile=c1614324985000
30
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-Debug__RPI_.mk=c1615797916000
31
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-variables.mk=c1615797916000
32
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/.gitignore=c1614324985000
33
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/messages.cpp=c1614324985000
34
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/nbproject/Makefile-Debug__PC_.mk=c1614324985000
35
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/base64/compile-and-run-test=c1614324985000
36
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/superviseur.doxygen=c1614324985000
37
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/base64/base64.cpp=c1614324985000
38
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/lib/camera.h=c1614324985000
39
+/home/tali/Temps_Reel/dumber/software/raspberry/superviseur-robot/main.cpp=c1614324985000

+ 152
- 43
software/raspberry/superviseur-robot/tasks.cpp View File

@@ -26,6 +26,8 @@
26 26
 #define PRIORITY_TRECEIVEFROMMON 25
27 27
 #define PRIORITY_TSTARTROBOT 20
28 28
 #define PRIORITY_TCAMERA 21
29
+#define PRIORITY_TWATCHDOG 35
30
+#define PRIORITY_TBATTERY 20
29 31
 
30 32
 /*
31 33
  * Some remarks:
@@ -135,7 +137,7 @@ void Tasks::Init() {
135 137
         cerr << "Error task create: " << strerror(-err) << endl << flush;
136 138
         exit(EXIT_FAILURE);
137 139
     }
138
-    if (err = rt_task_create(&th_battery, "th_battery", 0, PRIORITY_TMOVE, 0)) {
140
+    if (err = rt_task_create(&th_battery, "th_battery", 0, PRIORITY_TBATTERY, 0)) {
139 141
         cerr << "Error task create: " << strerror(-err) << endl << flush;
140 142
         exit(EXIT_FAILURE);
141 143
     }
@@ -143,15 +145,15 @@ void Tasks::Init() {
143 145
         cerr << "Error task create: " << strerror(-err) << endl << flush;
144 146
         exit(EXIT_FAILURE);
145 147
     }
146
-    if (err = rt_task_create(&th_watchdog, "th_watchdog", 0, PRIORITY_TMOVE, 0)) {
148
+    if (err = rt_task_create(&th_watchdog, "th_watchdog", 0, PRIORITY_TWATCHDOG, 0)) {
147 149
         cerr << "Error task create: " << strerror(-err) << endl << flush;
148 150
         exit(EXIT_FAILURE);
149 151
     }
150
-    if (err = rt_task_create(&th_camera, "th_camera", 0, PRIORITY_TMOVE, 0)) {
152
+    if (err = rt_task_create(&th_camera, "th_camera", 0, PRIORITY_TCAMERA, 0)) {
151 153
         cerr << "Error task create: " << strerror(-err) << endl << flush;
152 154
         exit(EXIT_FAILURE);
153 155
     }
154
-    if (err = rt_task_create(&th_startCamera, "th_startCamera", 0, PRIORITY_TMOVE, 0)) {
156
+    if (err = rt_task_create(&th_startCamera, "th_startCamera", 0, PRIORITY_TCAMERA, 0)) {
155 157
         cerr << "Error task create: " << strerror(-err) << endl << flush;
156 158
         exit(EXIT_FAILURE);
157 159
     }
@@ -284,6 +286,7 @@ void Tasks::SendToMonTask(void* arg) {
284 286
  */
285 287
 void Tasks::ReceiveFromMonTask(void *arg) {
286 288
     Message *msgRcv;
289
+    int err;
287 290
     
288 291
     cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
289 292
     // Synchronization barrier (waiting that all tasks are starting)
@@ -292,31 +295,70 @@ void Tasks::ReceiveFromMonTask(void *arg) {
292 295
     /**************************************************************************************/
293 296
     /* The task receiveFromMon starts here                                                */
294 297
     /**************************************************************************************/
295
-    rt_sem_p(&sem_serverOk, TM_INFINITE);
296
-    cout << "Received message from monitor activated" << endl << flush;
298
+    while(1){
299
+        rt_sem_p(&sem_serverOk, TM_INFINITE);
300
+        cout << "Received message from monitor activated" << endl << flush;
301
+        while (1) {
302
+            msgRcv = monitor.Read();
303
+            cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
297 304
 
298
-    while (1) {
299
-        msgRcv = monitor.Read();
300
-        cout << "Rcv <= " << msgRcv->ToString() << endl << flush;
301
-
302
-        if (msgRcv->CompareID(MESSAGE_MONITOR_LOST)) {
303
-            delete(msgRcv);
304
-            exit(-1);
305
-        } else if (msgRcv->CompareID(MESSAGE_ROBOT_COM_OPEN)) {
306
-            rt_sem_v(&sem_openComRobot);
307
-        } else if (msgRcv->CompareID(MESSAGE_ROBOT_START_WITHOUT_WD)) {
308
-            rt_sem_v(&sem_startRobot);
309
-        } else if (msgRcv->CompareID(MESSAGE_ROBOT_GO_FORWARD) ||
310
-                msgRcv->CompareID(MESSAGE_ROBOT_GO_BACKWARD) ||
311
-                msgRcv->CompareID(MESSAGE_ROBOT_GO_LEFT) ||
312
-                msgRcv->CompareID(MESSAGE_ROBOT_GO_RIGHT) ||
313
-                msgRcv->CompareID(MESSAGE_ROBOT_STOP)) {
314
-
315
-            rt_mutex_acquire(&mutex_move, TM_INFINITE);
316
-            move = msgRcv->GetID();
317
-            rt_mutex_release(&mutex_move);
305
+            if (msgRcv->CompareID(MESSAGE_MONITOR_LOST)) {
306
+                cout << "On est dans le message monitor lost" << endl << flush;
307
+
308
+                rt_mutex_acquire(&mutex_robot, TM_INFINITE);
309
+                int cpMove = MESSAGE_ROBOT_STOP;
310
+                robot.Write(new Message((MessageID)cpMove));
311
+                rt_mutex_release(&mutex_robot);
312
+                robot.Close();
313
+                monitor.Close();
314
+                rt_mutex_acquire(&mutex_move, TM_INFINITE);
315
+                move = MESSAGE_ROBOT_STOP;
316
+                rt_mutex_release(&mutex_move);
317
+                rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
318
+                robotStarted = 0;
319
+                rt_mutex_release(&mutex_robotStarted);
320
+                rt_mutex_acquire(&mutex_watchdog, TM_INFINITE);
321
+                watchdog = 0;
322
+                rt_mutex_release(&mutex_watchdog);
323
+                //Close Camrera + etatCamera
324
+                /* if (err = rt_task_delete(&th_server)) {
325
+                    cerr << "Error task delete: " << strerror(-err) << endl << flush;
326
+                    //exit(EXIT_FAILURE);
327
+                } */
328
+                if (err = rt_task_create(&th_server, "th_server", 0, PRIORITY_TSERVER, 0)) {
329
+                    cerr << "Error task create: " << strerror(-err) << endl << flush;
330
+                    exit(EXIT_FAILURE);
331
+                } 
332
+                if (err = rt_task_start(&th_server, (void(*)(void*)) & Tasks::ServerTask, this)) {
333
+                    cerr << "Error task start: " << strerror(-err) << endl << flush;
334
+                    exit(EXIT_FAILURE);
335
+                }
336
+                rt_sem_v(&sem_barrier);
337
+                Kill_StartWD();
338
+                break;
339
+            } else if (msgRcv->CompareID(MESSAGE_ROBOT_COM_OPEN)) {
340
+                rt_sem_v(&sem_openComRobot);
341
+            } else if (msgRcv->CompareID(MESSAGE_ROBOT_START_WITHOUT_WD)) {
342
+                rt_sem_v(&sem_startRobot);
343
+            } else if (msgRcv->CompareID(MESSAGE_ROBOT_GO_FORWARD) ||
344
+                    msgRcv->CompareID(MESSAGE_ROBOT_GO_BACKWARD) ||
345
+                    msgRcv->CompareID(MESSAGE_ROBOT_GO_LEFT) ||
346
+                    msgRcv->CompareID(MESSAGE_ROBOT_GO_RIGHT) ||
347
+                    msgRcv->CompareID(MESSAGE_ROBOT_STOP)) {
348
+                rt_mutex_acquire(&mutex_move, TM_INFINITE);
349
+                move = msgRcv->GetID();
350
+                rt_mutex_release(&mutex_move);
351
+                cout << "On est dans le message mouvement" << endl << flush;
352
+            }
353
+            else if (msgRcv->CompareID(MESSAGE_ROBOT_START_WITH_WD)){
354
+                rt_mutex_acquire(&mutex_watchdog, TM_INFINITE);
355
+                watchdog = 1;
356
+                rt_mutex_release(&mutex_watchdog);
357
+                rt_sem_v(&sem_startRobot);
358
+                cout << "On a start le robot avec Watchdog" << endl << flush;
359
+            }
360
+            delete(msgRcv); // mus be deleted manually, no consumer
318 361
         }
319
-        delete(msgRcv); // mus be deleted manually, no consumer
320 362
     }
321 363
 }
322 364
 
@@ -357,6 +399,7 @@ void Tasks::OpenComRobot(void *arg) {
357 399
  * @brief Thread starting the communication with the robot.
358 400
  */
359 401
 void Tasks::StartRobotTask(void *arg) {
402
+    int etatWD;
360 403
     cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
361 404
     // Synchronization barrier (waiting that all tasks are starting)
362 405
     rt_sem_p(&sem_barrier, TM_INFINITE);
@@ -365,23 +408,47 @@ void Tasks::StartRobotTask(void *arg) {
365 408
     /* The task startRobot starts here                                                    */
366 409
     /**************************************************************************************/
367 410
     while (1) {
368
-
411
+        
369 412
         Message * msgSend;
370 413
         rt_sem_p(&sem_startRobot, TM_INFINITE);
371
-        cout << "Start robot without watchdog (";
414
+        cout << "Start robot (";
372 415
         rt_mutex_acquire(&mutex_robot, TM_INFINITE);
373
-        msgSend = robot.Write(robot.StartWithoutWD());
374
-        rt_mutex_release(&mutex_robot);
375
-        cout << msgSend->GetID();
376
-        cout << ")" << endl;
416
+        rt_mutex_acquire(&mutex_watchdog, TM_INFINITE);
417
+        etatWD = watchdog;
418
+        rt_mutex_release(&mutex_watchdog);
419
+        cout << "Watchdog = " << etatWD << endl << flush;
420
+        if (etatWD == 0){
421
+            cout << "Dans le if without WD" << etatWD << endl << flush;
422
+            msgSend = robot.Write(robot.StartWithoutWD());
423
+            rt_mutex_release(&mutex_robot);
424
+            cout << msgSend->GetID();
425
+            cout << ")" << endl;
377 426
 
378
-        cout << "Movement answer: " << msgSend->ToString() << endl << flush;
379
-        WriteInQueue(&q_messageToMon, msgSend);  // msgSend will be deleted by sendToMon
427
+            cout << "Movement answer: " << msgSend->ToString() << endl << flush;
428
+            WriteInQueue(&q_messageToMon, msgSend);  // msgSend will be deleted by sendToMon
380 429
 
381
-        if (msgSend->GetID() == MESSAGE_ANSWER_ACK) {
382
-            rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
383
-            robotStarted = 1;
384
-            rt_mutex_release(&mutex_robotStarted);
430
+            if (msgSend->GetID() == MESSAGE_ANSWER_ACK) {
431
+                rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
432
+                robotStarted = 1;
433
+                rt_mutex_release(&mutex_robotStarted);
434
+            }
435
+        }
436
+        else{
437
+            cout << "Dans le if with WD" << etatWD << endl << flush;
438
+            msgSend = robot.Write(robot.StartWithWD());
439
+            rt_mutex_release(&mutex_robot);
440
+            cout << msgSend->GetID();
441
+            cout << ")" << endl;
442
+
443
+            cout << "Movement answer: " << msgSend->ToString() << endl << flush;
444
+            WriteInQueue(&q_messageToMon, msgSend);  // msgSend will be deleted by sendToMon
445
+
446
+            if (msgSend->GetID() == MESSAGE_ANSWER_ACK) {
447
+                rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
448
+                robotStarted = 1;
449
+                rt_mutex_release(&mutex_robotStarted);
450
+                rt_sem_v(&sem_startWD);
451
+            }
385 452
         }
386 453
     }
387 454
 }
@@ -393,7 +460,10 @@ void Tasks::MoveTask(void *arg) {
393 460
     int rs;
394 461
     int cpMove;
395 462
     int previousMove = -1;
463
+    int cpt = 0;
464
+    
396 465
     
466
+    Message * response;
397 467
     cout << "Start " << __PRETTY_FUNCTION__ << endl << flush;
398 468
     // Synchronization barrier (waiting that all tasks are starting)
399 469
     rt_sem_p(&sem_barrier, TM_INFINITE);
@@ -418,8 +488,27 @@ void Tasks::MoveTask(void *arg) {
418 488
                 cout << " move: " << cpMove;
419 489
 
420 490
                 rt_mutex_acquire(&mutex_robot, TM_INFINITE);
421
-                robot.Write(new Message((MessageID)cpMove));
491
+                response = robot.Write(new Message((MessageID)cpMove));
422 492
                 rt_mutex_release(&mutex_robot);
493
+                
494
+                if (response->CompareID(MESSAGE_ANSWER_ACK)){
495
+                    cpt = 0;
496
+                }
497
+                else{
498
+                    cpt++;
499
+                    if (cpt == 3){
500
+                        Message * respToMon = new Message(MESSAGE_ANSWER_COM_ERROR);
501
+                        WriteInQueue(&q_messageToMon,respToMon);
502
+                        rt_mutex_acquire(&mutex_robotStarted, TM_INFINITE);
503
+                        robotStarted = 0;
504
+                        rt_mutex_release(&mutex_robotStarted);
505
+                        rt_mutex_acquire(&mutex_watchdog, TM_INFINITE);
506
+                        watchdog = 0;
507
+                        rt_mutex_release(&mutex_watchdog);
508
+                        Kill_StartWD();
509
+                        cpt = 0;
510
+                    }
511
+                }
423 512
                 previousMove = cpMove;
424 513
             }
425 514
         }
@@ -428,6 +517,26 @@ void Tasks::MoveTask(void *arg) {
428 517
 }
429 518
 
430 519
 /**
520
+ * @brief Kills and restart the thread watchdog
521
+ */
522
+void Tasks::Kill_StartWD(){
523
+    int err;
524
+    if (err = rt_task_delete(&th_watchdog)) {
525
+        cerr << "Error task delete: " << strerror(-err) << endl << flush;
526
+        exit(EXIT_FAILURE);
527
+    }
528
+    if (err = rt_task_create(&th_watchdog, "th_watchdog", 0, PRIORITY_TWATCHDOG, 0)) {
529
+        cerr << "Error task create: " << strerror(-err) << endl << flush;
530
+        exit(EXIT_FAILURE);
531
+    }
532
+    if (err = rt_task_start(&th_watchdog, (void(*)(void*)) & Tasks::ReloadWatchdogTask, this)) {
533
+        cerr << "Error task start: " << strerror(-err) << endl << flush;
534
+        exit(EXIT_FAILURE);
535
+    }
536
+    rt_sem_broadcast(&sem_barrier);
537
+}
538
+
539
+/**
431 540
  * Write a message in a given queue
432 541
  * @param queue Queue identifier
433 542
  * @param msg Message to be stored
@@ -504,11 +613,11 @@ void Tasks::ReloadWatchdogTask(void *arg) {
504 613
     
505 614
     //We wait for the signal startWd
506 615
     rt_sem_p(&sem_startWD, TM_INFINITE);
507
-    
616
+    cout << "thread WD started" << endl << flush;
508 617
         /**************************************************************************************/
509 618
     /* The task starts here                                                               */
510 619
     /**************************************************************************************/
511
-    rt_task_set_periodic(NULL, TM_NOW, 50000000);
620
+    rt_task_set_periodic(NULL, TM_NOW, 1000000000);
512 621
     
513 622
     while(1){
514 623
         rt_task_wait_period(NULL);
@@ -519,7 +628,7 @@ void Tasks::ReloadWatchdogTask(void *arg) {
519 628
             cout << "Periodic watchdog reload" << endl << flush;
520 629
             
521 630
             rt_mutex_acquire(&mutex_robot, TM_INFINITE);
522
-            responseBattery = robot.Write(new Message(MESSAGE_ROBOT_RELOAD_WD));
631
+            robot.Write(new Message(MESSAGE_ROBOT_RELOAD_WD));
523 632
             rt_mutex_release(&mutex_robot);
524 633
         }
525 634
     }

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

@@ -70,10 +70,11 @@ private:
70 70
         int cameraStarted = 0;
71 71
         int getImg = 0;
72 72
         int askArena = 0;
73
-        Arena arena = void;
73
+        Arena* arena = new Arena();
74 74
         int getPos = 0;
75 75
     };
76 76
     struct etatCamera_t etatCamera;
77
+    int watchdog = 0;
77 78
     
78 79
     /**********************************************************************/
79 80
     /* Tasks                                                              */
@@ -163,6 +164,11 @@ private:
163 164
     */
164 165
    void ReloadWatchdogTask(void *arg);
165 166
    
167
+   /**
168
+    * @brief Kills and restart the thread watchdog
169
+    */
170
+    void Kill_StartWD();
171
+   
166 172
     /**********************************************************************/
167 173
     /* Queue services                                                     */
168 174
     /**********************************************************************/

Loading…
Cancel
Save