procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
tmpArray:array[0..4096] of Byte;
ArraySize,i: DWORD;
Count:DWORD;
tmpStr:string;
pStr:PChar;
begin
if Check1.Checked then
begin
pStr:=Buffer;
tmpStr:=string(pStr);
Dec(PStr); {pstr:=pstr-1; }
for i:=0 to Length(tmpStr)-1 do
begin
inc(PStr); {pstr:=pstr+1; }
tmpArray[i]:=Byte(PSTR^);
Memo2.Lines.Add(IntToHEX(Ord(tmpArray[i]),2));
end;
exit;
end;
pStr:= Buffer;
memo2.Lines.Add(pStr);
end;谁能帮忙给注释一下啊?
哪个变量是接收到的数据16进制?
BufferLength: Word);
var
tmpArray:array[0..4096] of Byte;
ArraySize,i: DWORD;
Count:DWORD;
tmpStr:string;
pStr:PChar;
begin
if Check1.Checked then
begin
pStr:=Buffer;
tmpStr:=string(pStr);
Dec(PStr); {pstr:=pstr-1; }
for i:=0 to Length(tmpStr)-1 do
begin
inc(PStr); {pstr:=pstr+1; }
tmpArray[i]:=Byte(PSTR^);
Memo2.Lines.Add(IntToHEX(Ord(tmpArray[i]),2));
end;
exit;
end;
pStr:= Buffer;
memo2.Lines.Add(pStr);
end;谁能帮忙给注释一下啊?
哪个变量是接收到的数据16进制?
tmpArray:array[0..4095] of Byte;
begin
if Check1.Checked then
begin
move(Buffer^,tmpArray[0],BufferLength);
for i:=0 to BufferLength-1 do
begin
strHex:=strHex+format('%.2x ',[tmpArray[0]]);//转换成16进制
end;
end;
end;
strHex:=strHex+format('%.2x ',[tmpArray[i]]);//转换成16进制