포트를 여러개 열면 왜 느려지죠? - 소스포함 - 살려주세요
다른 작업을 열심히 해서 느려지는것 같지는 않은데요
포트를 12개 열어서 타이머를 1개만으로 12개에 데이타 전송을 하면
느려지네요..
사용 컴포넌트는 CPort 구요...
뭐가 문제일까요..분명 소프트웨어 적인 문제 같은데..
-------------------- 추가 사항 -----------------
Timer.Interval := 200 입니다.
1번포트 부터 12번 포트까지 1바퀴까지는 잘 됩니다..
근데 두바퀴째 Write 부터 먹통됩니다.. ㅡ.ㅡ 꼭 좀 도와주세요
procedure TForm1.FormCreate(Sender: TObject);
var
i : Integer;
begin
SendMode := true;
PortNum := 1;
for i:=1 to 12 do
begin
ComPort[i] := TComPort.Create(self);
ComPort[i].Port := 'COM' + IntToStr(i+2);
ComPort[i].BaudRate := br2400;
ComPort[i].Buffer.InputSize := 400;
ComPort[i].Buffer.OutputSize := 400;
// ComPort[i].Parity
ComPort[i].EventChar := #0;
ComPort[i].Events := [evRxChar,evTxEmpty,evRxFlag,evRing,evBreak,evCTS,evDSR,evError,evRLSD,evRx80Full];
ComPort[i].FlowControl.ControlDTR := dtrDisable;
ComPort[i].FlowControl.ControlRTS := rtsDisable;
ComPort[i].FlowControl.FlowControl := fcCustom;
ComPort[i].FlowControl.DSRSensitivity := false;
ComPort[i].FlowControl.OutCTSFlow := false;
ComPort[i].FlowControl.OutDSRFlow := false;
ComPort[i].FlowControl.TxContinueOnXoff := false;
ComPort[i].FlowControl.XonChar := #17;
ComPort[i].FlowControl.XoffChar := #19;
ComPort[i].FlowControl.XonXoffOut := false;
ComPort[i].FlowControl.XonXoffOut := false;
ComPort[i].Parity.Bits := prNone;
ComPort[i].Parity.Check := false;
ComPort[i].Parity.Replace := false;
ComPort[i].parity.ReplaceChar := #0;
ComPort[i].StopBits := sbOneStopBit;
ComPort[i].SyncMethod := smThreadSync;
ComPort[i].Timeouts.ReadInterval := -1;
ComPort[i].Timeouts.ReadTotalConstant := 0;
ComPort[i].Timeouts.ReadTotalMultiplier := 0;
ComPort[i].Timeouts.WriteTotalMultiplier := 100;
ComPort[i].Timeouts.WriteTotalConstant := 1000;
ComPort[i].Open;
// ComPort[i].Connected := true;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
tmp : String;
TmpBuff : Array [1..400] of byte;
begin
if SendMode = true then
begin
// ComPort[PortNum].ClearBuffer(true,false);
// ComPort1.WriteStr('111111111');
ComPort[PortNum].WriteStr('SSSSSSSSSS');
TMemo(FindComponent('Memo'+IntToStr(PortNum))).Lines.Add('SSSSSSSSS');
if PortNum < 12 then
begin
Inc(PortNum);
end
else
begin
SendMode := false;
PortNum := 1;
end;
end
else
begin
// ComPort[PortNum].ClearBuffer(false,true);
{
tmp := '';
if ComPort[PortNum].InputCount > 0 then
begin
// ComPort[PortNum].Read()
ComPort[PortNum].Readstr(tmp,ComPort[PortNum].InputCount);
tmp := 'Recv : ' + tmp;
TMemo(FindComponent('Memo'+IntToStr(PortNum))).Lines.Add(tmp);
end;
}
if PortNum < 12 then
begin
Inc(PortNum)
end
else
begin
SendMode := true;
PortNum := 1;
end;
end;
end;