资源简介
一种有限状态机(FSM)的C语言实现,在事件中判断状态。

代码片段和文件信息
/*
* Copyright (c) 2013 Andreas Misje
*
* Permission is hereby granted free of charge to any person obtaining a
* copy of this software and associated documentation files (the “Software“)
* to deal in the Software without restriction including without limitation
* the rights to use copy modify merge publish distribute sublicense
* and/or sell copies of the Software and to permit persons to whom the
* Software is furnished to do so subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS“ WITHOUT WARRANTY OF ANY KIND EXPRESS OR
* IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER
* LIABILITY WHETHER IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING
* FROM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include
#include
#include “stateMachine.h“
/* This simple example checks keyboad input against the two allowed strings
* “ha\n“ and “hi\n“. If an unrecognised character is read a group state will
* handle this by printing a message and returning to the idle state. If the
* character ‘!‘ is encountered a “reset“ message is printed and the group
* state‘s entry state will be entered (the idle state).
*
* print ‘reset‘
* o +---------------------+
* | | | ‘!‘
* | v group state |
* +-----v-----------------------------------+----+
* | +------+ ‘h‘ +---+ ‘a‘ +---+ ‘\n‘ |
* +->| idle | ----> | h | ----> | a | ---------+ |
* | +------+ +---+\ +---+ | |
* | ^ ^ ^ \‘i‘ +---+ ‘\n‘ | |
* | | | | \--> | i | ------+ | |
* | | | | +---+ | | |
* +---|-|-|----------------+----------------|--|-+
* | | | | | |
* | | | | ‘[^hai!\n]‘ | |
* | | | print unrecog. | | |
* | | +----------------+ print ‘hi‘ | |
* | +-----------------------------------+ |
* | print ‘ha‘ |
* +----------------------------------------+
*/
/* Types of events */
enum eventType {
Event_keyboard
};
/* Compare keyboard character from transition‘s condition variable against
* data in event. */
static bool compareKeyboardChar( void *ch struct event *event );
static void printRecognisedChar( void *stateData struct event *event );
static void printUnrecognisedChar( void *oldStateData struct event *event
void *newStateData );
static void printReset( void *oldStateData struct event *event
void *newStateData );
static void prin
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-11-06 20:02 stateMachine-master\
文件 42 2014-03-21 05:29 stateMachine-master\.gitignore
文件 1082 2014-03-21 05:29 stateMachine-master\LICENSE.md
文件 172 2014-03-21 05:29 stateMachine-master\Makefile
文件 211 2014-03-21 05:29 stateMachine-master\README.md
目录 0 2018-11-06 20:02 stateMachine-master\doc\
文件 76449 2014-03-21 05:29 stateMachine-master\doc\doxyconfig
目录 0 2018-11-06 20:02 stateMachine-master\doc\img\
文件 3493 2014-03-21 05:29 stateMachine-master\doc\img\logo.png
文件 36326 2014-03-21 05:29 stateMachine-master\doc\img\stateMachine.svg
目录 0 2018-11-06 20:02 stateMachine-master\examples\
文件 7586 2014-03-21 05:29 stateMachine-master\examples\stateMachineExample.c
目录 0 2018-11-06 20:02 stateMachine-master\src\
文件 5630 2014-03-21 05:29 stateMachine-master\src\stateMachine.c
文件 17378 2014-03-21 05:29 stateMachine-master\src\stateMachine.h
目录 0 2018-11-06 20:02 stateMachine-master\tests\
文件 9684 2014-03-21 05:29 stateMachine-master\tests\nestedTest.c
- 上一篇:简易学生信息管理系统
- 下一篇:机械手臂运动程序
相关资源
- STM32F207通过http更新固件
- BOOTloder_stm32f407
- STM32读CS1237实现秤重测量
- 基于STM32单片机的心率体温测量仪
- 基于STM32F103ZET6控制舵机旋转(ts90a/
- stm32f103zet6控制蓝牙小车
- STM32F407驱动OLED显示DS18B20数字温度
- vscode作为编辑器开发stm32f103c8
- STM32 多路PWM输出
- STM32烧写算法flash包
- STM32 LIN通信数据发送实现 测试通过
- FFT电流检测 stm32f4
- DS1302万年历设计 stm32
- 超声波定高(基于STM32)
- STM32(神舟III号 串口1发送实验程序)
- STM32 模拟信号采集
- STM32-ads1256
- STM32跑马灯实验58159
- STM32429的串口收发程序
- STM32连接EC20使用内置MQTT协议接入阿里
- ADS1256-STM32参考程序
- stm32 AD7506
- STM32F10实现照相功能照相机
- 基于STM32的嵌入式flash读写控制
- stm32f103c8t6开发板原理图+pcb
- STM32内部FLASH模拟eerom
- stm32的半导体除湿机程序
- stm32实现高精度频率测定
- stm32库函数代码自动生成器V1.2
- stm32 DMA例程
评论
共有 条评论