串口通讯

来源:互联网 发布:广联达 gcf软件 编辑:程序博客网 时间:2024/04/30 15:10

Serial library for C++

Introduction

Serial communications is needed in several types of applications, but the Win32 API isn't a very easy to use API to implement it. Things get even more complicated when you want to use serial communication in an MFC based program. The classes provided in the library try to make life a little easier. Its documentation is extensive, because I want to give you a good background. Serial communication is hard and good knowledge of its implementation saves you a lot of work, both now and in the future...


http://www.codeproject.com/KB/system/serial.aspx



Serial Communication in Windows

Introduction

This article is meant to give you a jump start on doing serial communicationin Windows (NT family). The article will provide a class calledCSerialCommHelper which you can use directly to do serial communication in yourapplication. The class that is provided here with this article does usesoverlapped IO. You donot need to know much about serial communication oroverlapped IO for this article. However, you need to know some about thesynchronization objects like Events and some Windows APIs likeWaitForSingleObject and WaitForMultipleObject etc. Also some basic understandingof windows threads is required - like thread creation and termination.

Introduction

In order for your computer to be able to do serial communication, computerhas to have a serial port. Most of the computers have at least one serial portalso known as COM port ( communication port ) and are generally called COM1 COM2etc. Then there are the device drivers for the serial ports. If you think itover, all you that you need to do in serial communication is either send data orreceive data. In other words, you are doing input/output (IO) to the serialport. The same IO is done with disk based files. Hence there is no surprise thatthe APIs for reading and writing to a file apply to serial ports as well. Whenyou send data to the serial port its in terms of bytes but when it leaves theserial port it is in the form of bits. Similarly, when the data arrives at theserial port, its in bit format and when you get data you get it in bytes.

http://www.codeproject.com/KB/system/serial_com.aspx

原创粉丝点击