]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
robofsm: Reworked robot termination
authorMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 15 Mar 2009 20:43:51 +0000 (21:43 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 15 Mar 2009 20:43:51 +0000 (21:43 +0100)
The previous implementation called orte destroy in robot_exit(), which
is being called from signal handler and thus it caould cause deadlocks.
Now, ORTE is destroyed in in robot_destroy(), which is always called
from the main thread.

src/robofsm/fsmdisplay.c
src/robofsm/robot.c
src/robofsm/robot.h

index 36f4597e0a69807df76609d43ed6d09d367a388b..60b798bfad400899f4d98067b7cd930d34708358 100644 (file)
@@ -163,7 +163,6 @@ int process_msg(uint8_t *buff) {
                        robot_exit();
                        break;
                case ROBOT_RESTART:
-                       robot_orte_destroy();
                        system("killall ortemanager");
                        system("killall cand");
                        robot_exit();
index e84c1397162f7f6ced1c38b893ec9ff8c8e5b70a..019b032ae0fa3084a8d26606a05913c7bf0a3ed3 100644 (file)
@@ -211,33 +211,10 @@ err:
        return rv;
 }
 
-/** 
- * Destroy ORTE stuffs.
- *
- * @return 0
- */
-int robot_orte_destroy()
-{
-       robot.orte.laser_cmd.speed = LASER_DRIVE_OFF;
-       ORTEPublicationSend(robot.orte.publication_laser_cmd);
-       ORTEPublicationSend(robot.orte.publication_laser_cmd);
-
-       off_brush_left();
-       off_brush_right();
-       robot.orte.motion_speed.right = 0;
-       robot.orte.motion_speed.left = 0;
-       ORTEPublicationSend(robot.orte.publication_motion_speed);                       
-       
-       robottype_roboorte_destroy(&robot.orte);
-
-       return 0;
-}
-
 /** 
  * Signals all the robot threads to finish.
- * @return 0
  */
-int robot_exit()
+void robot_exit()
 {
        int i;
 
@@ -246,20 +223,29 @@ int robot_exit()
                fsm_exit(&robot.fsm[i]);
        }
 
-       robot_orte_destroy();
-
        return 0;
 }
 
 /** 
  * Stops the robot. All resources alocated by robot_init() or
  * robot_start() are dealocated here.
- * @return 0
  */
-int robot_destroy()
+void robot_destroy()
 {
        int i;
 
+       robot.orte.laser_cmd.speed = LASER_DRIVE_OFF;
+       ORTEPublicationSend(robot.orte.publication_laser_cmd);
+       ORTEPublicationSend(robot.orte.publication_laser_cmd);
+
+       off_brush_left();
+       off_brush_right();
+       robot.orte.motion_speed.right = 0;
+       robot.orte.motion_speed.left = 0;
+       ORTEPublicationSend(robot.orte.publication_motion_speed);                       
+       
+       robottype_roboorte_destroy(&robot.orte);
+
        for (i=0; i<FSM_CNT; i++)
                fsm_destroy(&robot.fsm[i]);
        DBG("robofsm: stop.\n");
index b5d273e346208549fb998c8088e055b70d45bcc1..34546d74b9b66a4823c02452d1f725c0c732a903 100644 (file)
@@ -211,11 +211,10 @@ extern struct robot_eb2008 robot;
 extern "C" {
 #endif 
 
-int __attribute__ ((warn_unused_result)) robot_init();
-int __attribute__ ((warn_unused_result)) robot_start();
-int robot_exit();
-int robot_destroy();
-int robot_orte_destroy();
+int robot_init() __attribute__ ((warn_unused_result));
+int robot_start() __attribute__ ((warn_unused_result));
+void robot_exit();
+void robot_destroy();
 
 /* Hack to easily disable display if it is not configured */
 void serial_comm(int status);