⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fsm.h

📁 linuxFedure4环境下串口编程后台运行状态机
💻 H
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -