基于Vc串口通信的数据发送实现.doc
文本预览下载声明
基于VC++的串口通信飞行仿真数据传输
摘 要
介绍了采用Visual C++6.0中的MSComm控件来实现串口通信的基本原理,如何利用Win32的底层API函数开发串口通信类CserialPort,与Microsoft Commuinications Control 控件相比,采用该串口通信类对串口设备操作时,能够在一定程度上避免对串口设备的“屏蔽”。增加对串口操作的透明度,提高串口传输数据的可靠性。针对Visual C++6.0具有功能强大,通信快速,实时性好等特点,介绍基于Visual C++的一种串口通信原理及其实现方法,并针对控制系统众多界面下串口通信的多线程等特点,结合实例阐述通信模块化等一些技巧。应用电脑对外界数据进行直观的图形绘制。
Windows环境下地串口编程与DOS环境下的串口编程有很大的不同。Windows环境下的最大特点之一就是设备无关性,它通过设备驱动程序将Windows应用程序同不同的外部设备隔离。Windows封装了Windows的通信机制,这种方式称为通信API,Windows程序员可以利用Windows通信API进行编程,不用对硬件直接进行操作。这种体系被称为Windows开放式服务体系。
Windows 9x/NT/2000中的API一般都支持32位的操作,因此又称为Win32 API。Windows操作系统是一个可抢占式的操作系统,所以Windows应用程序常常有被别的程序抢占时间片的可能,因此Win32通信业不能用于实时通信。实时通信的质量与时间紧密相关。因此,不需要许多协议层的交换式、非实时的通信可以采用Win32通信API来实现。Win32通信API把串口操作和文件操作统一起来,使用类似的操作来实现通信。
关键词:VC++,嵌入式系统,,MSComm,,Windows API, 串口通信, 模块化,图形,绘制.
ABSTRACT
This paper introduces the Visual C + +6.0 of MSComm control to achieve the basic principles of serial communication, how to use the underlying Win32 serial communication API function to develop type CserialPort, and Microsoft Commuinications Control control compared to using the serial communication type of Serial equipment operation, to a certain extent, the serial device to avoid the shieldIncrease the transparency of the operation of serial port, serial port to improve the reliability of data transmission. For Visual C + +6.0 with powerful rapid communications, real-time characteristics of a good to introduce the Visual C + + based on a principle of serial communication and its implementation, and control system for the many serial communication interface, such as multi-threading characteristics, with examples such as the modular communication skillsApplication of computer to the outside world intuitive graphical data mapping.
Windows environment Shimoji serial programming and serial DOS programming environment are very different from.Windows environment is one of the greatest characteristics of device-independent,it will be through the device driver with Windows application
显示全部