C
candylyg
Unregistered / Unconfirmed
GUEST, unregistred user!
分太少,当是我的全部,不好意思.
我用spcomm控件连接单片机.
单片机主动.并隔一段施加发送一个 9511 请求信息.
PC机在收到这一信息后必须在马上(极短时间)发送指令 指令为 95EE1368,单片机才会响应.
响应的确认信息为 953313B5
我的代码如下,为什么不能收到确认信息?
isSended:boolean=false;
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
bufByteArray;
test,test1:string;
sbuf:array[1..4] of byte;
begin
sbuf[1]:=byte($95);
sbuf[2]:=byte($EE);
sbuf[3]:=byte($13);
sbuf[4]:=byte($68);
Buf:=PByteArray(Buffer);
test:=inttohex(buf[0],2)+inttohex(buf[1],2);
test1:=inttohex(buf[0],2)+inttohex(buf[1],2)+inttohex(buf[2],2)+inttohex(buf[3],2);
if test='9511' then
begin
if not isSended then
comm1.writeCommData(@sbuf[1],length(sbuf));
/////////////
end else if test1='953313B5' then
begin
isSended:=True;
form1.Caption :='successed!';
end;
我用spcomm控件连接单片机.
单片机主动.并隔一段施加发送一个 9511 请求信息.
PC机在收到这一信息后必须在马上(极短时间)发送指令 指令为 95EE1368,单片机才会响应.
响应的确认信息为 953313B5
我的代码如下,为什么不能收到确认信息?
isSended:boolean=false;
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
bufByteArray;
test,test1:string;
sbuf:array[1..4] of byte;
begin
sbuf[1]:=byte($95);
sbuf[2]:=byte($EE);
sbuf[3]:=byte($13);
sbuf[4]:=byte($68);
Buf:=PByteArray(Buffer);
test:=inttohex(buf[0],2)+inttohex(buf[1],2);
test1:=inttohex(buf[0],2)+inttohex(buf[1],2)+inttohex(buf[2],2)+inttohex(buf[3],2);
if test='9511' then
begin
if not isSended then
comm1.writeCommData(@sbuf[1],length(sbuf));
/////////////
end else if test1='953313B5' then
begin
isSended:=True;
form1.Caption :='successed!';
end;