J
juzihuangle
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure senddata;
var
i:integer;
commflg:boolean;
begin
viewstring:='';
commflg:=true;
for i:=1 to 1 do
begin
if not fcomm.comm1.writecommdata(@sbuf,1) then
begin
commflg:=false;
break;
end;
sleep(1);
viewstring:=viewstring+inttohex(sbuf,2);
end;
viewstring:='发送'+viewstring;
fcomm.memo1.lines.add(viewstring);
fcomm.memo1.lines.add('');
if not commflg then messagedlg('发送失败!',mterror,[mbyes],0);
end;
procedure TFCOMM.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var i:integer;
rbuf:array[0..16] of byte;
begin
viewstring:='';
move(buffer^,pchar(@rbuf)^,bufferlength);
for i:=0 to bufferlength-1 do
viewstring:=viewstring+inttohex(rbuf,2);
viewstring:='接收'+viewstring;
memo2.lines.add(viewstring);
memo2.lines.add('');
end;
var
i:integer;
commflg:boolean;
begin
viewstring:='';
commflg:=true;
for i:=1 to 1 do
begin
if not fcomm.comm1.writecommdata(@sbuf,1) then
begin
commflg:=false;
break;
end;
sleep(1);
viewstring:=viewstring+inttohex(sbuf,2);
end;
viewstring:='发送'+viewstring;
fcomm.memo1.lines.add(viewstring);
fcomm.memo1.lines.add('');
if not commflg then messagedlg('发送失败!',mterror,[mbyes],0);
end;
procedure TFCOMM.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var i:integer;
rbuf:array[0..16] of byte;
begin
viewstring:='';
move(buffer^,pchar(@rbuf)^,bufferlength);
for i:=0 to bufferlength-1 do
viewstring:=viewstring+inttohex(rbuf,2);
viewstring:='接收'+viewstring;
memo2.lines.add(viewstring);
memo2.lines.add('');
end;