readfile()函数想取出MODED的接收缓冲区的数据,却取出了MODEM的发送缓冲区的数据,为什么? 如下EscapeCommFunction(hcommfile,CLRRTS );
EscapeCommFunction(hcommfile,CLRDTR );
readdata2:='';
inputdata2:=pchar('');
ClearCommError(hcommfile, errs, @stat );
if @stat=nil then exit;
inputdatalen2:= stat.cbInQue;
if inputdatalen2=0 then exit;
try
inputdata2:=allocmem(inputdatalen2);
tempdata2:=inputdata2;
if not ReadFile(hcommfile, inputdata2^, inputdatalen2, nRead,nil) then
raise ECommsError.Create('接收失败!');
setlength(temps,nread);
for i:=1 to inputdatalen2 do
begin
temps[i]:=tempdata2^;
inc(tempdata2);
end;
readdata2:=temps;
finally
freemem(inputdata2);//清;
end;单步调试,发现的readdata2的值是发送缓冲区的数据
EscapeCommFunction(hcommfile,CLRDTR );
readdata2:='';
inputdata2:=pchar('');
ClearCommError(hcommfile, errs, @stat );
if @stat=nil then exit;
inputdatalen2:= stat.cbInQue;
if inputdatalen2=0 then exit;
try
inputdata2:=allocmem(inputdatalen2);
tempdata2:=inputdata2;
if not ReadFile(hcommfile, inputdata2^, inputdatalen2, nRead,nil) then
raise ECommsError.Create('接收失败!');
setlength(temps,nread);
for i:=1 to inputdatalen2 do
begin
temps[i]:=tempdata2^;
inc(tempdata2);
end;
readdata2:=temps;
finally
freemem(inputdata2);//清;
end;单步调试,发现的readdata2的值是发送缓冲区的数据
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货