延时?如何做
procedure TForm1.ConvertToPos;
var i,ptr:integer;
buf,next_buf:array [0..255] of byte;
flag:boolean;
lrc : byte;
begin
ptr := 0;
flag := false;
lrc :=0;
for i := 0 to 255 do begin
buf := ord(#0);
next_buf := ord(#0);
end;
if High(DataBuf) > 7 then
flag := True;
for i:= low(DataBuf) to High(DataBuf) do
begin
if high(DataBuf) = 15 then
begin
if i <= 7 then begin
move(DataBuf[0], buf[ptr], 8);
move(DataBuf[8], buf[128+ptr], 8);
end
else begin
move(DataBuf[0], next_buf[ptr], 8);
move(DataBuf[8], next_buf[128+ptr], 8);
end;
inc(ptr, 8);
end
else if high(DataBuf) = 31 then
begin
if i <= 7 then begin
move(DataBuf[0], buf[ptr], 8);
move(DataBuf[16], buf[ptr+8], 8);
move(DataBuf[8], buf[128+ptr], 8);
move(DataBuf[24], buf[128+8+ptr], 8);
end
else
begin
move(DataBuf[0], next_buf[ptr], 8);
move(DataBuf[16], next_buf[ptr+8], 8);
move(DataBuf[8], next_buf[128+ptr], 8);
move(DataBuf[24], next_buf[128+8+ptr], 8);
end;
inc(ptr, 16);
end;
end;//end for
txbuf[0] := $02; //ENAC_STX
txbuf[1] := $05;
txbuf[2] := $14;
txbuf[3] := $ff;
move(buf[0], txbuf[4], 256);
if flag then
txbuf[260] := $ff
else txbuf[260] := $00;
move(next_buf[0], txbuf[261], 256);
txbuf[517] := $03; //ENAC_ETX
for i := 1 to 517 do
lrc := lrc xor txbuf;
txbuf[518] := lrc;
comm1.WriteCommData(@txbuf,519);
end;