P
pihome
Unregistered / Unconfirmed
GUEST, unregistred user!
看你上面写的,应该是程序写错了
procedure TForm1.Button1Click(Sender: TObject);
var
Buf: Array[1..259] of Byte;
begin
//comm1.WriteCommData('64',1); 你这里写的是字符串 64,是两个字节了
Buf[1]:=64;
Comm1.WriteCommData(@Buf,1);
end;
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
Buf: PChar;
begin
GetMem(Buf,BufferLength*2);
BinToHex(PChar(Buffer),Buf,BufferLength); //转成16进制字符器显示出来
Memo1.Lines.Add(StrPas(Buf));
FreeMem(Buf);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Buf: Array[1..259] of Byte;
begin
//comm1.WriteCommData('64',1); 你这里写的是字符串 64,是两个字节了
Buf[1]:=64;
Comm1.WriteCommData(@Buf,1);
end;
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
Buf: PChar;
begin
GetMem(Buf,BufferLength*2);
BinToHex(PChar(Buffer),Buf,BufferLength); //转成16进制字符器显示出来
Memo1.Lines.Add(StrPas(Buf));
FreeMem(Buf);
end;