关于CPORT3.0控件和串口通讯!!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, CPort, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ComPort1: TComPort;
procedure Button1Click(Sender: TObject);
procedure ComPort1RxBuf(Sender: TObject; const Buffer; Count: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
ComPort1.Open;
ComPort1.WriteStr('AT'+#13);
ComPort1.OnRxBuf:=ComPort1RxBuf;
end;
procedure TForm1.ComPort1RxBuf(Sender: TObject; const Buffer;
Count: Integer);
begin
showmessage('ok');
end;
end.
********************************************************************
上面是我写的测试程序,为什么RxBuf没有反应呢??RxChar就可以用。。。
问题点数:50、回复次数:3Top
1 楼gemouzhi(^_^)回复于 2005-02-07 15:04:56 得分 50
你用ComPort1.Write(const buffer; count: Integer)试试Top
2 楼sfwss(小凯)回复于 2005-02-07 19:06:34 得分 0
我跟踪运行,发现在CPORT.pas中的
procedure TComThread.DoEvents;
begin
if evError in FEvents then
FComPort.CallError;
if evRxChar in FEvents then
FComPort.CallRxChar;
if evTxEmpty in FEvents then
FComPort.CallTxEmpty;
if evBreak in FEvents then
FComPort.CallBreak;
if evRing in FEvents then
FComPort.CallRing;
if evCTS in FEvents then
FComPort.CallCTSChange;
if evDSR in FEvents then
FComPort.CallDSRChange;
if evRxFlag in FEvents then
FComPort.CallRxFlag;
if evRLSD in FEvents then
FComPort.CallRLSDChange;
if evRx80Full in FEvents then
FComPort.CallRx80Full;
end;
这段里就没有CallRxBuf 呀。。。Top
3 楼sfwss(小凯)回复于 2005-02-09 01:36:34 得分 0
没人知道吗????顶上去Top




