#include "fsm.h"
#include <stdio.h>
+#include <string.h>
const char *fsm_common_event_str(fsm_event ev)
{
fsm->event = event; /* Set what to handle */
/* This does all the magic */
- if (fsm->state)
- while ((ret_code = fsm->state(fsm)) != RC_WAIT);
+ if (fsm->state) {
+ do {
+ ret_code = fsm->state(fsm);
+ } while (ret_code != RC_WAIT);
+ }
else
fprintf(stderr, "FSM %s: fnc->act is NULL!!!\n", fsm->debug_name);
fsm->event.id = EV_NOEVENT;
*/
void fsm_init(struct robo_fsm *fsm, char *debug_name)
{
+ memset(fsm, 0, sizeof(*fsm));
/* Execute EV_INIT immediately after start. */
fsm_event first_event = { EV_INIT, NULL };
fsm->sent_event = first_event;
#include <unistd.h>
-#include <robot_eb2007.h>
-#include <robodata.h>
#include <fsm.h>
+#include <stdio.h>
+
+#define DBG(f, a...) printf(f, ## a)
+#define fsm_event_str fsm_common_event_str
FSM_STATE(state1)
{