用MSCOMM通过串口从工业秤中读重量数据
用MSCOMM通过串口从工业秤中读重量数据
procedure TForm1.MSComm1Comm(Sender: TObject);
var
STX:string;
begin
case MSComm1.CommEvent of
......
comEvCTS: exit; //有时进入该清除发送通信事件,我不希望该事件
comEvReceive: //我需要进入接收事件,我希望该事件
begin
strWei:= MSComm1.Input ;
STX:=MidStr(strWei,1,1);
if STX= #2 then
begin
iWei:= strtoint(MidStr(strWei,5,6));
edit1.Text:= inttostr(iWei) ;
MSComm1.InBufferCount := 0;
MSComm1.PortOpen :=false;
if MSComm1.PortOpen =false then
begin
sleep(100);
MSComm1.PortOpen :=true;
end;
end;
end;
end;
end;
CTS信号线的状态经常发生变化,影响我接受数据,怎样才能在程序中屏蔽该信号线的状态