summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--digital/io/src/fsm.h4
-rw-r--r--digital/io/src/main.c33
2 files changed, 35 insertions, 2 deletions
diff --git a/digital/io/src/fsm.h b/digital/io/src/fsm.h
index ced9fadb..33c9a108 100644
--- a/digital/io/src/fsm.h
+++ b/digital/io/src/fsm.h
@@ -35,8 +35,8 @@
*
* if (asserv_move_cmd_status () == success)
* {
- * fsm_handle_event (fsm_top, TOP_EVENT_position_reached);
- * fsm_handle_event (fsm_getsamples, GETSAMPLES_EVENT_position_reached);
+ * fsm_handle_event (&top_fsm, TOP_EVENT_position_reached);
+ * fsm_handle_event (&getsamples_fsm, GETSAMPLES_EVENT_position_reached);
* }
*
* Any unhandled event will be ignored.
diff --git a/digital/io/src/main.c b/digital/io/src/main.c
index 20eace93..d03714c4 100644
--- a/digital/io/src/main.c
+++ b/digital/io/src/main.c
@@ -39,6 +39,7 @@
#include "asserv.h" /* Functions to control the asserv board */
#include "eeprom.h" /* Parameters loaded/stored in the EEPROM */
#include "trap.h" /* Trap module (trap_* functions) */
+#include "fsm.h" /* fsm_* */
#include "io.h"
@@ -100,6 +101,38 @@ main_loop (void)
if (asserv_last_cmd_ack () == 0)
/* Called function to manage retransmission */
asserv_retransmit ();
+ else
+ {
+ /* Check commands move status */
+ if (asserv_move_cmd_status () == success)
+ {
+ /* Pass it to all the FSM that need it */
+ fsm_handle_event (&getsamples_fsm,
+ GETSAMPLES_EVENT_bot_move_succeed);
+ }
+ else
+ {
+ /* Move failed */
+ fsm_handle_event (&getsamples_fsm,
+ GETSAMPLES_EVENT_bot_move_failed);
+ }
+ /* Check commands arm status */
+ if (asserv_arm_cmd_status () == success)
+ {
+ /* Pass it to all the FSM that need it */
+ fsm_handle_event (&getsamples_fsm,
+ GETSAMPLES_EVENT_arm_move_succeed);
+ }
+ /* TODO: Check if the sensor placed at the noted position has seen
+ * an arm passed and forward this event to the getsamples FSM */
+// if (arm_in_front_of_reached_position)
+// {
+// /* Reset the sensor back to see a new transit of the arm */
+// fsm_handle_event (&getsamples_fsm,
+// GETSAMPLES_EVENT_arm_pass_noted_position);
+// }
+ /* Check other sensors */
+ }
}
}