A Simple RS-232 Serial Port Communication Program

Interaction between target device and PC through RS-232 serial port is proved to be very useful in test process automation. Therefore,  the effectiveness and accuracy of the communication along with the design of the protocol is crucial to the success of the testing system. Although a lot of issues regarding relevant technical details which should surely be carefully dealt with may come up during the development of serial port communication program, there is no doubt that one should focus more on things like the deployment of the communcation and structure of the diagram rather than the nuts and bolts of the infrastructure such as the APIs. And only by prudently devising the scheme can one largely avoid those puzzles arises in the form of API inefficiencies, and even bugs.

Below is part of the code I wrote for the particular purpose of a project I'm working on.  It now supports a demo program offering simple but promising testing interaction.

 

== ETermTransceiver.h ==

 

The Transceiver module deals with routine work of serial port communication and leaves the message parsing to the protocol module (derivate of ETermProtocol, which is not covered here)

 

 

== ETermTransceiver.cpp ==

 

 

posted @ 2009-10-15 01:38  quanben  阅读(193)  评论(0编辑  收藏  举报