文件名称:spcomm 3.0 串口通信控件
文件大小:45KB
文件格式:RAR
更新时间:2013-09-14 02:14:36
spcomm 串口 控件
使用示例: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, SPComm, TeEngine, Series, ExtCtrls, TeeProcs, Chart; type TForm1 = class(TForm) Comm1: TComm; ComboBox1: TComboBox; ComboBox2: TComboBox; ComboBox3: TComboBox; ComboBox4: TComboBox; ComboBox5: TComboBox; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Button1: TButton; Memo1: TMemo; procedure Comm1ReceiveData(Sender: TObject; Buffer: Pointer; BufferLength: Word); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; Viewstring:string; i:integer; rbuf,sbuf:array[1..6] of byte; implementation {$R *.dfm} procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer; BufferLength: Word); var i:integer; begin viewstring:=' '; move(buffer^,pchar(@rbuf)^,bufferlength); for i:=1 to bufferlength do viewstring:=viewstring+inttohex(rbuf[i],2)+' '; viewstring:='接受'+viewstring; memo1.lines.add(viewstring); memo1.lines.add(' '); end; procedure TForm1.Button1Click(Sender: TObject); begin //判断按键的状态可以便面打开串口出错时,要按两次按键 if Button1.Caption = '打开串口' then begin // 串口初始化 //EnumComPorts(ComboBox1.Items);//得到串口列表 Comm1.CommName := ComboBox1.Text; Comm1.BaudRate := StrToInt(ComboBox2.Text); Comm1.Parity := None; //ComboBox3.Text Comm1.ByteSize := _8; //ComboBox4.Text Comm1.StopBits := _1; //ComboBox5.Text //########################################### Comm1.StartComm;//打开串口 Button1.Caption := '关闭串口'; ComboBox1.Enabled := false; ComboBox2.Enabled := false; ComboBox3.Enabled := false; ComboBox4.Enabled := false; ComboBox5.Enabled := false; //btnSend.Enabled := true; //ImageOff.Visible := false; //ImageOn.Visible := true; end else begin //############################################## Comm1.StopComm; // 关闭串口 Button1.Caption := '打开串口'; ComboBox1.Enabled := true; ComboBox2.Enabled := true; ComboBox3.Enabled := true; ComboBox4.Enabled := true; ComboBox5.Enabled := true; //btnSend.Enabled := false; //ImageOn.Visible := false; //ImageOff.Visible := true; end; end; end.
【文件预览】:
spcomm 3.0_串口通信
----SPCOMM.DCR(464B)
----SPComm.pas(62KB)
----spcommkongjian.dcu(3KB)
----SPComm.~pas(62KB)
----SPComm.dcu(26KB)
----PSComm.dcu(3KB)
----README.TXT(20KB)