没有可用请求时,才停止轮询消息队列

This commit is contained in:
nnhy 2015-12-11 12:35:51 +00:00
parent 7c96abb1fc
commit 429f6ea42f
1 changed files with 5 additions and 2 deletions

View File

@ -651,6 +651,10 @@ void TinyController::Loop()
auto& node = _Queue[i]; auto& node = _Queue[i];
if(!node.Using) continue; if(!node.Using) continue;
auto f = (TFlags*)&node.Data[3];
// 可用请求消息数,需要继续轮询
if(!f->_Reply) count++;
// 检查时间。至少发送一次 // 检查时间。至少发送一次
if(node.Times > 0) if(node.Times > 0)
{ {
@ -671,14 +675,12 @@ void TinyController::Loop()
msg_printf("重发消息 Dest=0x%02X Seq=0x%02X Times=%d\r\n", node.Data[0], node.Seq, node.Times + 1); msg_printf("重发消息 Dest=0x%02X Seq=0x%02X Times=%d\r\n", node.Data[0], node.Seq, node.Times + 1);
} }
count++;
node.Times++; node.Times++;
// 发送消息 // 发送消息
Port->Write(Array(node.Data, node.Length)); Port->Write(Array(node.Data, node.Length));
// 递增重试次数 // 递增重试次数
auto f = (TFlags*)&node.Data[3];
f->Retry++; f->Retry++;
// 请求消息列入统计 // 请求消息列入统计
@ -707,6 +709,7 @@ void TinyController::Loop()
} }
} }
// 没有可用请求时,停止轮询
if(count == 0) Sys.SetTask(_taskID, false); if(count == 0) Sys.SetTask(_taskID, false);
} }