CnPack Forum


 
Subject: CnModem错误报告
zj_yqj
新警察
Rank: 1



UID 2638
Digest Posts 0
Credits 27
Posts 9
点点分 27
Reading Access 10
Registered 2006-9-28
Status Offline
Post at 2009-3-28 10:08  Profile | Blog | P.M. 
CnModem错误报告

procedure TCnModem.Escape;
var
  Tick: Integer;
begin
  if CommOpened and (ModemState = msOnline) then
  begin
    Tick := Round(FWaitEscapeTime * 0.02 * 1.3);
    Sleep(Tick);
    WriteATCommand('+++', False);
    Sleep(Tick);
    ModemState := msOnlineCommand;
  end;
end;

这里的0.02应该为20.因为下面的Sleep中的单位是毫秒。
Top
zj_yqj
新警察
Rank: 1



UID 2638
Digest Posts 0
Credits 27
Posts 9
点点分 27
Reading Access 10
Registered 2006-9-28
Status Offline
Post at 2009-3-28 12:10  Profile | Blog | P.M. 
function TCnModem.WaitATResult(Delay: Cardinal): string;
var
  Tick: Cardinal;
begin
  FWaitATResult := True;
  try
    FATResult := '';
    Tick := GetTickCount;
    while (GetTickCount - Tick < Delay) and (FATResult = '') do
      Application.ProcessMessages;
    Result := FATResult;
    FATResult := '';
  finally
    FWaitATResult := False;
  end;
end;

Application.ProcessMessages;
后面要加一行
Sleep(1);
否则等待时CPU打满了了
Top
zjy
管理员
Rank: 9Rank: 9Rank: 9



UID 2
Digest Posts 6
Credits 2385
Posts 1543
点点分 2385
Reading Access 102
Registered 2002-12-16
Location China
Status Offline
Post at 2009-3-28 19:42  Profile | Site | Blog | P.M. 
感谢报告!

0.02 的问题估计是当初疏忽,刚才看到 SkyJacker 写的 Demo 里也提到了这个疑问,已改为 20。
ProcessMessages 修改为 HandleMessage,后者会调用 Idle,比 Sleep 更规范。

已提交 CVS,有空请验证。




Zhou JingYu
CnPack Administrator
http://www.cnpack.org/
Top
 




All times are GMT++8, the time now is 2024-11-25 02:08

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.006408 second(s), 7 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP