fsm.h
来自「linuxFedure4环境下串口编程后台运行状态机」· C头文件 代码 · 共 69 行
H
69 行
#ifndef FSM_H#define FSM_H#define MAX_SYMBOL_LEN 40/** * typedef of the callback function pointer type, * every callback function must be declared like: * void callback(const unsigned char *resource); */typedef void (*callback_ptr)(const unsigned char *resource);/** * an entry in the function table, see sample.c for detailed usage */struct func_table{ unsigned char symbol[MAX_SYMBOL_LEN]; callback_ptr func;};/** * we simply declare the existence of struct FSM here. the defination * is not exposed to end user */struct FSM;/** * create an FSM based on specified configuration file and function * table, return NULL on error */struct FSM *fsm_load(const unsigned char *filename, const struct func_table *funcv, int funcc);/** * trigger an event, callback function will be called and state will * be switched automatically, return zero on success */int fsm_doevent(struct FSM *fsm, const unsigned char *event);/** * switch to given state directly, without invoking callback functions */voidfsm_setstate(struct FSM *fsm, const unsigned char *state);/** * release an FSM created using fsm_load or fsm_create */void fsm_free(struct FSM *fsm);/** * create an empty FSM */struct FSM *fsm_create(const struct func_table *funcv, int funcc);/** * add an state transition rule to the given FSM */intfsm_add(struct FSM *fsm, const unsigned char *state, const unsigned char *event, const unsigned char *next, const unsigned char *func, const unsigned char *resource);#endif /* #ifdef FSM_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?