M
Michael
Hello world,
maybe this query is a little out of topic,
but I need a finite state machine in C.
I think plenty of people have already done
that, so I'm looking for some hints and
maybe strategies.
I already tried google, but the results are,
well, lets say uncountable
My approach was to define a state via a
struct, consisting mainly of three function
pointers:
stateAction ........... Does the Activity
stateTransition ....... Cares about the next states
stateInit ............. Called once to init
I have second struct combining holding an array of
pointers to all states and an Information about the
current one. My problem is how to put all the needed
data to the state-functions without global variables?
So far a created a struct of pointers and added a
pointer to this to the "state-struct". Is there a better
way (sure there is, isn't it)
Thanks in advance,
Michael
maybe this query is a little out of topic,
but I need a finite state machine in C.
I think plenty of people have already done
that, so I'm looking for some hints and
maybe strategies.
I already tried google, but the results are,
well, lets say uncountable
My approach was to define a state via a
struct, consisting mainly of three function
pointers:
stateAction ........... Does the Activity
stateTransition ....... Cares about the next states
stateInit ............. Called once to init
I have second struct combining holding an array of
pointers to all states and an Information about the
current one. My problem is how to put all the needed
data to the state-functions without global variables?
So far a created a struct of pointers and added a
pointer to this to the "state-struct". Is there a better
way (sure there is, isn't it)
Thanks in advance,
Michael