H
hubeizwj
Unregistered / Unconfirmed
GUEST, unregistred user!
用下面的接收代码取的数据一长串:用是反序的
如:重量:-0.34
取出的数为:43.000-=43.000-=43.000-=43.000-=
43.000-=43.000-=43.000-=43.000-=43.000-=
43.000-=43.000-=43.000-=43.000-=43.000-=
43.000-=43.000-=43.000-=43.000-=43.000-=
43.000-=43.000-=43.000-=43.000-=43.000-=
procedure TForm1.Comm1ReceiveData(Sender: TObject;
Buffer: Pointer;
BufferLength: Word);
var
tmpArray:array[0..4096] of Byte;
ArraySize,i: DWORD;
CountWORD;
tmpStr:string;
pStrChar;
begin
if Check1.Checked then
begin
pStr:=Buffer;
tmpStr:=string(pStr);
Dec(PStr);
for i:=0 to Length(tmpStr)-1do
begin
inc(PStr);
tmpArray:=Byte(PSTR^);
Memo2.Lines.Add(IntToHEX(Ord(tmpArray),2));
end;
exit;
end;
pStr:= Buffer;
memo2.Lines.Add(pStr);
end;
如:重量:-0.34
取出的数为:43.000-=43.000-=43.000-=43.000-=
43.000-=43.000-=43.000-=43.000-=43.000-=
43.000-=43.000-=43.000-=43.000-=43.000-=
43.000-=43.000-=43.000-=43.000-=43.000-=
43.000-=43.000-=43.000-=43.000-=43.000-=
procedure TForm1.Comm1ReceiveData(Sender: TObject;
Buffer: Pointer;
BufferLength: Word);
var
tmpArray:array[0..4096] of Byte;
ArraySize,i: DWORD;
CountWORD;
tmpStr:string;
pStrChar;
begin
if Check1.Checked then
begin
pStr:=Buffer;
tmpStr:=string(pStr);
Dec(PStr);
for i:=0 to Length(tmpStr)-1do
begin
inc(PStr);
tmpArray:=Byte(PSTR^);
Memo2.Lines.Add(IntToHEX(Ord(tmpArray),2));
end;
exit;
end;
pStr:= Buffer;
memo2.Lines.Add(pStr);
end;