计算机工程与应用 ›› 2011, Vol. 47 ›› Issue (9): 61-64.

• 研发、设计、测试 • 上一篇    下一篇

高效串口并发通信模型的研究

施孟佶,桂 勋,陈小平,刘 强   

  1. 电子科技大学 空天科学技术研究院,成都 610054
  • 收稿日期:1900-01-01 修回日期:1900-01-01 出版日期:2011-03-21 发布日期:2011-03-21

Research on effective serial port concurrent communication

SHI Mengji,GUI Xun,CHEN Xiaoping,LIU Qiang   

  1. Institute of Astronautics and Aeronautics,University of Electronic Science and Technology of China,Chengdu 610054,China
  • Received:1900-01-01 Revised:1900-01-01 Online:2011-03-21 Published:2011-03-21

摘要: 为满足现代工业自动化控制系统中的多串口并发通信需求,提出了基于完成端口机制在VC++开发平台上实现的高效解决方案。阐述了该方案的基本原理、实现流程,以及运行过程中常见问题的解决措施。该方案采用单件设计模式保证完成端口的唯一性,并通过更高层次的封装,解决了用户操作不便的问题。对比实验表明:在大量串口并发通信的情况下,相对于常见的未采用完成端口机制而使用专用线程处理重叠I/O的多串口通信解决方案,该方案具有更高的效率和更少的系统资源耗费。

关键词: 完成端口, 单件设计模式, 串口并发通信, VC++

Abstract: This paper provides an efficient solution to multiple serial concurrent communications,based on the I/O Completion Port(IOCP) mechanism in the VC++ development platform,to meet the communication needs in the modern industrial automation control systems.In addition to presenting the basic principles and the implementation process of this solution,this paper also provides the keys to some common runtime problems.In this solution,singleton design pattern is taken to ensure that there is only one completion port in each application,and problem of user inconvenience is solved with a higher level of package.The experimental results show that,in case of concurrent communication with a large number of serial ports,the solution is more efficient and with less consumption of system resource than the ones based on overlapped I/O which is now widely used.

Key words: I/O completion port, singleton design pattern, concurrent serial port communication, VC++