基于串口通信文件传输的实现.doc
文本预览下载声明
基于串口通信文件传输的实现
基于串口通信文件传输的实现
摘 要
计算机和计算机终端之间的数据传输,可以采用串行通信、并行通信和网卡通
信等方式,由于串口通信使用线路较少、成本较低,因此在远程监控、工业自动控
制和数据采集领域被广泛采用。Visual C++由于功能强大、应用灵活,与Microsoft
操作系统的兼容性较好,因此涉及硬件操作的通信编程,采用VC作为开发工具是
值得推荐的。在VC下进行串口编程,既可以使用Win32应用程序接口 API 函数,
也可以使用VC提供的MSComm控件。但是用API编写程序时往往要考虑多线程问题,
编写出的程序十分庞大,而且结构复杂、继承性差。本设计详细地介绍了串口通信
的概念,基本原理,参数,实现方式的基础上,然后自己定义了基于串口的通信协
议,使用VC++编写出测试程序,从而实现了串口与串口之间的文件的传输。
关键词:串口,通信,MSComm
I
基于串口通信文件传输的实现
Abstract
The data transmission between the computer and computer terminal, It can adapt
serial communication, parallel communication and Ethernet communication. It is
adapted broadly in the field such as long-range supervisory control, auto industry control
and data collection just because it use lower circuit and cost less. Visual C++ shorter
forms VC has powerful function and apply nimbly, and has fine compatibility with
Microsoft operate system 。So, communication programming relates hardware operating,
adopt VC to be exploitation implement is to be worth. Programming under VC, both can
use the Win32 application interface function and MSComm that VC provides. It is
necessary to often consider the multi-thread problem when you programming use API,
the compiling program is big, structure is complicated, and succession is bad. In this
article, it introduce that the concept, the basal principle, the parameter, and the realize
way of serial communication, and then have defined the communication protocol which
based on serial port by myself, write the program with VC++, At last it realize that the
file transform between serial port and serial port.
Key words :Serial port, Communication, MSCom
显示全部