procedure ControlCommReceiveData(Port:Integer; Buffer: Pointer; BufferLength: Integer);
var
tem, ErrMsg:String;
i : integer;
CurAlleyNO : integer;
CurAlley : TAlleyInfo;
CardId, StdId : string;
ComDataReault :integer;
begin
StdId := '';
try
try
if( not Assigned(zyCommData) ) then
Exit;
except
WriteEvent(DataM.LocalDBCnct, '判断zyComm是否为空出错');
end; if( ReceivingData = TRUE ) then
begin
ReceivingData := TRUE;
WriteEvent(LocalDataM.LocalDBCnct, SysEvent_BusyRecvData, EventType_SysCmd);
Exit;
end; ReceivingData := TRUE;
WriteEvent(DataM.LocalDBCnct, '接收数据开始');
try
tem := '';
for i:=0 to BufferLength-1 do
tem[i+1] := (Pchar(Buffer)+i)^; }
except
WriteEvent(DataM.LocalDBCnct, 'CCCCCCCCCCCCCCCC');
end;
try
if(zyCommData.GetData(tem, BufferLength)=-1) then//在下面
begin
ReceivingData := FALSE;
Exit;
end;
except
WriteEvent(DataM.LocalDBCnct, 'DDDDDDDDDDDDDDDDDD');
end; try
tem := zyCommData.Data;
except
WriteEvent(DataM.LocalDBCnct, 'EEEEEEEEEEEEEEEEEEE');
end;
except
WriteEvent(LocalDataM.LocalDBCnct, '1002');
ReceivingData := FALSE;
exit;
end;
end;function TSerialCommData.GetData(CommData:string; parDataLen:integer):Integer;
var
I : integer;
begin
Result := zyFailed;
try
try
if(CurLen=0) and (parDataLen>0) then
begin
CurLen := 0;
Data := '';
if( CommDataLenType = DLT_VarLen ) then
begin
DataLen := Integer(CommData[1]);
if(( DataLen <> 15 ) and ( DataLen<>20 ) and ( DataLen<>45 )) and (CommData[1] <> #3)then
begin
Exit;
end;
end;
end;
except
WriteEvent(LocalDataM.LocalDBCnct,'判断错误');
end; for I:=1 to parDataLen Do
begin
try
Data := Data + char(CommData[I]);
except
WriteEvent(LocalDataM.LocalDBCnct, '拼接数据出错AAAA');
end; try
Inc(CurLen);
if( curLen = DataLen ) then
begin
Result := zySuccess;
CurLen := 0;
break;
end;
except
WriteEvent(LocalDataM.LocalDBCnct,'拼接数据出错BBBB');
end;
end;
except
WriteEvent(LocalDataM.LocalDBCnct,'拼接数据出错');
end;
end;
var
tem, ErrMsg:String;
i : integer;
CurAlleyNO : integer;
CurAlley : TAlleyInfo;
CardId, StdId : string;
ComDataReault :integer;
begin
StdId := '';
try
try
if( not Assigned(zyCommData) ) then
Exit;
except
WriteEvent(DataM.LocalDBCnct, '判断zyComm是否为空出错');
end; if( ReceivingData = TRUE ) then
begin
ReceivingData := TRUE;
WriteEvent(LocalDataM.LocalDBCnct, SysEvent_BusyRecvData, EventType_SysCmd);
Exit;
end; ReceivingData := TRUE;
WriteEvent(DataM.LocalDBCnct, '接收数据开始');
try
tem := '';
for i:=0 to BufferLength-1 do
tem[i+1] := (Pchar(Buffer)+i)^; }
except
WriteEvent(DataM.LocalDBCnct, 'CCCCCCCCCCCCCCCC');
end;
try
if(zyCommData.GetData(tem, BufferLength)=-1) then//在下面
begin
ReceivingData := FALSE;
Exit;
end;
except
WriteEvent(DataM.LocalDBCnct, 'DDDDDDDDDDDDDDDDDD');
end; try
tem := zyCommData.Data;
except
WriteEvent(DataM.LocalDBCnct, 'EEEEEEEEEEEEEEEEEEE');
end;
except
WriteEvent(LocalDataM.LocalDBCnct, '1002');
ReceivingData := FALSE;
exit;
end;
end;function TSerialCommData.GetData(CommData:string; parDataLen:integer):Integer;
var
I : integer;
begin
Result := zyFailed;
try
try
if(CurLen=0) and (parDataLen>0) then
begin
CurLen := 0;
Data := '';
if( CommDataLenType = DLT_VarLen ) then
begin
DataLen := Integer(CommData[1]);
if(( DataLen <> 15 ) and ( DataLen<>20 ) and ( DataLen<>45 )) and (CommData[1] <> #3)then
begin
Exit;
end;
end;
end;
except
WriteEvent(LocalDataM.LocalDBCnct,'判断错误');
end; for I:=1 to parDataLen Do
begin
try
Data := Data + char(CommData[I]);
except
WriteEvent(LocalDataM.LocalDBCnct, '拼接数据出错AAAA');
end; try
Inc(CurLen);
if( curLen = DataLen ) then
begin
Result := zySuccess;
CurLen := 0;
break;
end;
except
WriteEvent(LocalDataM.LocalDBCnct,'拼接数据出错BBBB');
end;
end;
except
WriteEvent(LocalDataM.LocalDBCnct,'拼接数据出错');
end;
end;
if( ReceivingData = TRUE ) then
begin
ReceivingData := TRUE;//這句代碼起碼是無用的。
WriteEvent(LocalDataM.LocalDBCnct, SysEvent_BusyRecvData, EventType_SysCmd);
Exit;
end;
tem := zyCommData.Data;
Data := Data + char(CommData[I]);
这两句话运行时间长会有错误
对对对,这个是没什么用
tem := zyCommData.Data;
Data := Data + char(CommData[I]);
这两句话运行时间长会有错误
Data := Data + char(CommData[I]);
String 是动态重新分配内存 Data := Data +CommData;这样行不?
String 长度也有限制的
而且curlen=0的时候data :='';