使用 c++builder 的串口通讯源代码
在网上很难找到 C++串口通信的源码,因此我将刚做好的程序源码公开。当中如有 bug,烦请告知,以便
对学习者负责。此程序仅供串口初学者学习。
我已经在 windows 2000 下编译测试通过。因为此程序针对厂内一种仪表所编,请按自己情况修改。但
核心部分是不需修改的。
界面右侧可以输入数字进行测试,注意最后请跟一个回车键,测试时将 RS-232 接口的第 2,第 3 针连接,
即可进行自发送,自接收。
可以随便转载,但请保持完整 --- masa。
程序中使用了 windows API 函数,unit2.h unit2.cpp 为监视线程,没有窗口。
#########
//--------------unit.h-----------
#ifndef UnitH
#de$ne UnitH
//-----------------------------------
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE 管理のコンポーネント
TRadioGroup *RadioGroup1;
TButton *Button3;
TButton *Button4;
TButton *Button5;
TMemo *Memo2;
TLabel *Label2;
TImage *Image1;
TGroupBox *GroupBox1;
TEdit *Edit1;
TEdit *Edit2;
TLabel *Label3;
TLabel *Label4;
TLabel *Label12;
TComboBox *ComboBox3;
TLabel *Label7;
TLabeledEdit *LabeledEdit1;