摘要
VC++ 串口通讯程序在WIN32下通常不直接对端口进行操作 ,在WIN32中所有的设备都被看成是文件 ,串行口也不例外。文章详细介绍了文件I/O函数提供的打开和关闭通信资源句柄及读写操作的基本接口 (Create File、ReadFile、WriteFile等 ) ,举例说明了在VC 环境下如何通过WindowsAPI通信函数实现对串口的操作。新的文件I/O函数支持重叠式输入输出 ,使线程可从费时的I/O操作中解放出来 。
It is not commended to directly access the COM port in WIN32 serial communication. All devices in WIN32 are regarded as files,which naturally include the COM port. The new I/O function,such as CreateFile,ReadFile and WriteFile,are introduced in detail here,and giving an application example to use windows API communication function to access COM port in VC++. These I/O function support overlapped operator,such makes the application example thread have enough time to process its task and not waiting for I/O operation. The Asynchronous method greatly improves executing efficiency.
出处
《石油仪器》
2003年第6期44-47,62,共4页
Petroleum Instruments