|
摘要: |
串口通信程序多是用微软提供的MSComm控件实现的,但MSComm控件实现方法很难加入多线程技术提高程序的执行效率,尤其对微机与多台智能设备之间同时进行通信,这种方法的单线程局限性就更明显。为此,深入介绍了32位串口通信的结构体和WindowsAPI函数及多线程编程技术,,并结合面向对象的编程思想,将WindowsAPI函数、结构体及多线程技术进行了封装,形成新的串口通信类CCommunication,该类可以实现MSComm控件的所有功能,用该类开发的程序比用MSComm控件开发的程序的执行速度快。应用该类可很方便地实现基于Visual C 7.0多线程串口通信,且具有通用性好,使用性强等优点。 |
关键词: VisualC++7.0 多线程 串口通信 MSComm控件 面向对象 程序设计 |
DOI: |
分类号:TP311.1 |
基金项目: |
|
Implementation of multithread serial communication with Visual C+ +7.0 |
LI Dong xiao LI Xiao ming XIAO Kun ZHANG Fa zhong PENG Jia yin
|
Abstract: |
Most serial communication programs are developed with MSComm control supplied by Microsoft,but Multithread technology could not be easily added into it.The defect is more noteworthy in multi CPU communication.The structs and Windows API functions of 32?bit serial communication and the multithread programming technique are introduced.According to the OOP,the structs and functions are encapsulated to form a new class CCommunication.It can realize all the functions produced by MSComm control,and the efficiency of the program developed with it is better than that with the MSComm control.The multithread serial communication programming based on Visual C++7.0 becomes easier with better transplantability and practicability. |
Key words: Visual C++7.0,Windows API,struct,multithread,serial communication, |