unit Unit1;interfaceuses
  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就可以用

解决方案 »

  1.   

    你用ComPort1.Write(const buffer; count: Integer)试试
      

  2.   

    我跟踪运行,发现在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 呀