T
tarzar
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TF_power.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
count,data :integer;
data_head :integer;//用来放'X'($58)
begin
move(buffer^,Receive_Buff,BufferLength);//把接收到的数据放Recive_Buff绶冲区中,move是system库的过程
//BufferLength接收的字符的长度
Receive_Main_Count := Receive_Main_Count + BufferLength;//主指针计数
//只要收到的数有大于一包数据的长度,就处理
while (Receive_Main_Count >= PACK_LEN ) do子 //PACK_LEN 是常数9
begin
//找数据包的头
for count:=1 to Receive_Main_Count do
begin
data_head := Receive_Buff[count];
Receive_Main_Count := Receive_Main_Count - 1;
if(data_head = $58)then
break;
end;
//取数据包
Data_Buff[1] := data_head;
for count := 2 to 9 do
begin
Data_Buff[count] := Receive_Buff[count];
end;
show_to_Receive_Memo;//显示到memo
data_of_receive_process;//数据处理
Receive_Main_Count := Receive_Main_Count - 8;
end;
end;
这是SPComm串行通信控件的接收事件
我想的问题:
我它接收到一串七个字符时,,则进入该事件
按程序来看,,Receive_Main_Count >= PACK_LEN 应该为假,,所以按这段程序的流程应该是退出才对但它却没有,而是跳去执行<data_of_receive_process;//数据处理>这一过程
BufferLength: Word);
var
count,data :integer;
data_head :integer;//用来放'X'($58)
begin
move(buffer^,Receive_Buff,BufferLength);//把接收到的数据放Recive_Buff绶冲区中,move是system库的过程
//BufferLength接收的字符的长度
Receive_Main_Count := Receive_Main_Count + BufferLength;//主指针计数
//只要收到的数有大于一包数据的长度,就处理
while (Receive_Main_Count >= PACK_LEN ) do子 //PACK_LEN 是常数9
begin
//找数据包的头
for count:=1 to Receive_Main_Count do
begin
data_head := Receive_Buff[count];
Receive_Main_Count := Receive_Main_Count - 1;
if(data_head = $58)then
break;
end;
//取数据包
Data_Buff[1] := data_head;
for count := 2 to 9 do
begin
Data_Buff[count] := Receive_Buff[count];
end;
show_to_Receive_Memo;//显示到memo
data_of_receive_process;//数据处理
Receive_Main_Count := Receive_Main_Count - 8;
end;
end;
这是SPComm串行通信控件的接收事件
我想的问题:
我它接收到一串七个字符时,,则进入该事件
按程序来看,,Receive_Main_Count >= PACK_LEN 应该为假,,所以按这段程序的流程应该是退出才对但它却没有,而是跳去执行<data_of_receive_process;//数据处理>这一过程