首页 | 本学科首页   官方微博 | 高级检索  
     

一种基于状态机的串口通信协议的设计与实现
引用本文:李莹,贾彬.一种基于状态机的串口通信协议的设计与实现[J].电子设计工程,2012,20(7):100-103,107.
作者姓名:李莹  贾彬
作者单位:1. 太原理工大学信息工程学院,山西太原,030024
2. 山西省万立科技有限公司,山西太原,030032
摘    要:为解决串口通信中的数据传输容易出错、可靠性差、安全性不高且容错能力低等问题,设计并实现了一种基于状态机的串口通信协议,并将此协议应用到称重仪表的上位机通信中。本文介绍了串口通信协议的数据包格式以及其通信状态机,并给出了协议实现的部分示例代码及算法流程图。在数据包格式定义中通过设置起始标志、数据长度、校验、结束标志等字段,保证数据传输的正确性;并在数据包接收过程中引入状态机方法,简化编程模型的同时,提高了通信过程的可靠性、安全性以及数据传输的容错能力。

关 键 词:状态机  串口  通信协议  ATmega168  线程

Design and implementation of serial port communication protocol based on state machine
LI Ying,JIA Bin.Design and implementation of serial port communication protocol based on state machine[J].Electronic Design Engineering,2012,20(7):100-103,107.
Authors:LI Ying  JIA Bin
Affiliation:1.College of Information Engineering,Taiyuan University of Technology,Taiyuan 030024,China; 2.Wanli Science and Technology Co.,LTD of Shanxi Province,Taiyuan 030032,China)
Abstract:A serial port communication protocol based on state machine which is designed and implemented in order to solve the problems such as data transmission errors,poor reliability,low security and fault tolerance,is applied to a weighing instrument’s PC communication.This paper mainly describes the serial port communication protocol data packet format and its communication state machine,and also gives some code of the protocol and algorithm flow chart Start flag,data length,calibration,and end flag are set to ensure the correctness of data transmission.And state machine is used in the data packet receiving course to simplify programming model,and improve the reliability,security and fault tolerance.
Keywords:state machine  serial port  communication protocol  ATmega168  thread
本文献已被 CNKI 万方数据 等数据库收录!
设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司  京ICP备09084417号