求助呀,100分!(100分)

  • 主题发起人 主题发起人 abc516
  • 开始时间 开始时间
A

abc516

Unregistered / Unconfirmed
GUEST, unregistred user!
发‘0’给COM。延时,发55H给COM然后接收,我已经成功接收。然后再发04H给COM。再接收,我没有接收到。再发04H给COM。再接收,我没有接收到。
烦大侠帮我看看。
var
strinput:string;
strtxt:String;
txtsql:String;
sss:String;
sss1:String;
sss2:String;
inTinputlen:integer;
k:Integer;
i:Integer;

btmp:byte;
ovtmp:olevariant;
vtmp:variant;
k1:Integer;
i1:Integer;

btmp1:byte;
ovtmp1:olevariant;
vtmp1:variant;
k2:Integer;
i2:Integer;

btmp2:byte;
ovtmp2:olevariant;
vtmp2:variant;

byTinput:array[0..9] of Byte;
receive:array[0..8] of Byte;
begin
sss:=#$30;
sss1:=#$55;
sss2:=#$04;
If MSComm1.PortOpen= True Then MSComm1.PortOpen:= False;
MSComm1.InBufferSize:=1024;
MSComm1.OutBufferSize:=512;
MSComm1.PortOpen:=True;
MSComm1.Output:= strtxt;
sleep(600);
MSComm1.InBufferCount:=0;
MSComm1.InputMode:= comInputModeBinary;
mscomm1.Output:=sss1;
sleep(30);
MSComm1.InputLen := 9 ;
K:=mscomm1.InBufferCount;
ovtmp:=mscomm1.input;
vtmp:=vararraycreate([0,127],varbyte);
vtmp:=ovtmp;
strinput:='' ;
for i:=1 to k-1 do
begin
btmp:=vtmp;
memo1.Text:=memo1.Text+inttostr(btmp);
end;

//上面的接收成绩了。但是下面第一次发04H却没有接收到什么

mscomm1.InBufferCount:=0;
mscomm1.Output:=sss2;
MSComm1.InputLen := 9 ;
K1:=mscomm1.InBufferCount;
sleep(60);
ovtmp1:=mscomm1.input;

showmessage(inttostr(k1)) ;
vtmp1:=vararraycreate([0,127],varbyte);
vtmp1:=ovtmp1;
strinput:='' ;
for i1:=1 to k1-1 do
begin
btmp1:=vtmp1[i1];
memo1.Text:=memo1.Text+inttostr(btmp1);
end;
//第二次发04H给COM

mscomm1.Output:=sss2;
MSComm1.InputLen := 9 ;
inTinputlen:= 9 ;
K:=mscomm1.InBufferCount;
sleep(30);
ovtmp2:=mscomm1.input;
vtmp2:=vararraycreate([0,127],varbyte);
vtmp2:=ovtmp2;
strinput:='' ;
MEMO1.Text:=MEMO1.Text+'以后的是第二个04的';
for i2:=1 to k2-1 do
begin
btmp2:=vtmp2[i2];
memo1.Text:=memo1.Text+inttostr(btmp2);
end;
end;
 
上例中的MSComm1.Output:= strtxt;呢STRTXT曾被赋值'0'


 
后退
顶部