procedure TForm1.Button1Click(Sender: TObject);
begin
 senddata(edit1.text);      发送edit1中的字符串
 edit2.Text :=recdata;      接受到的字符串显示在edit2中procedure senddata(s:string); 发送函数没有问题
var comandstr:string;
begin
  comandstr:=s+char(13);
  form1.comm1.writecommdata(pchar(ComandStr),length(ComandStr));
end;procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;接受函数 edit2不能显示收到的字符串  BufferLength: Word);
begin
    move(Buffer^, PChar(@RecData[1])^, BufferLength);
end;

解决方案 »

  1.   

    spcom中$11和$13是被流控制占用了
    spcom代码修改如下:
    constructor TComm.Create( AOwner: TComponent );
    begin
         inherited Create( AOwner );     ReadThread := nil;
         WriteThread := nil;
         hCommFile := 0;
         hCloseEvent := 0;
         FSendDataEmpty := True;     FCommName := 'COM1';
         FBaudRate := 9600;
         FParityCheck := False;
         FOutx_CtsFlow := False;
         FOutx_DsrFlow := False;
         FDtrControl := DtrEnable;
         FDsrSensitivity := False;
         FTxContinueOnXoff := True;
         FOutx_XonXoffFlow := False;
         FInx_XonXoffFlow := False;
              改为False
         FReplaceWhenParityError := False;
         FIgnoreNullChar := False;
         FRtsControl := RtsEnable;
         FXonLimit := 500;
         FXoffLimit := 500;
         FByteSize := _8;
         FParity := None;
         FStopBits := _1;
         FXonChar := chr($11);      // Ctrl-Q
         FXoffChar := chr($13);     // Ctrl-S
         FReplacedChar := chr(0);
         FReadIntervalTimeout         := 5;
         FReadTotalTimeoutMultiplier  := 0;
         FReadTotalTimeoutConstant    := 0;
         FWriteTotalTimeoutMultiplier := 0;
         FWriteTotalTimeoutConstant   := 0;     if not (csDesigning in ComponentState) then
            FHWnd := AllocateHWnd(CommWndProc)
    end;就OK了,我遇到过这个问题的
      

  2.   

    SetLength(RecData,BufferLength);
    move(Buffer^, PChar(@RecData[1])^, BufferLength);
    edit2.text:=RecData