M
mouse369
Unregistered / Unconfirmed
GUEST, unregistred user!
我使用CPORT做通讯,在接收数据时不能一次全部将发送来数据接收完,有时可以,有时要分两次。如何解决?谢谢各位大虾!
procedure set;
begin
ComPort.Close;
ComPort.BaudRate:=StrToBaudRate('br9600');
ComPort.Port:='com1';
ComPort.DataBits:=StrToDataBits('dbEight');
ComPort.StopBits:=StrToStopBits('sbOneStopBit');
ComPort.Parity.Bits:=StrToParity('prNone');
ComPort.FlowControl.FlowControl:=StrToFlowControl('fcNone');
ComPort.FlowControl.ControlDTR := dtrEnable;
ComPort.FlowControl.ControlRTS := rtsEnable;
ComPort.Buffer.InputSize:=4096;
ComPort.Open;
ComPort.WriteStr('1234567890');
end;
procedure TForm_Assay.ComPortRxChar(Sender: TObject; Count: Integer);
var
S_Gather:string;
begin
ComPort.ReadStr(S_Gather,ComPort.Buffer.InputSize);
ComPort.ClearBuffer(true,true);
end;
procedure set;
begin
ComPort.Close;
ComPort.BaudRate:=StrToBaudRate('br9600');
ComPort.Port:='com1';
ComPort.DataBits:=StrToDataBits('dbEight');
ComPort.StopBits:=StrToStopBits('sbOneStopBit');
ComPort.Parity.Bits:=StrToParity('prNone');
ComPort.FlowControl.FlowControl:=StrToFlowControl('fcNone');
ComPort.FlowControl.ControlDTR := dtrEnable;
ComPort.FlowControl.ControlRTS := rtsEnable;
ComPort.Buffer.InputSize:=4096;
ComPort.Open;
ComPort.WriteStr('1234567890');
end;
procedure TForm_Assay.ComPortRxChar(Sender: TObject; Count: Integer);
var
S_Gather:string;
begin
ComPort.ReadStr(S_Gather,ComPort.Buffer.InputSize);
ComPort.ClearBuffer(true,true);
end;