Esp8266::Send大于一定时间的等待,不要堵塞其它任务发送数据

This commit is contained in:
Stone 2016-08-02 04:28:55 +00:00
parent c775515aa7
commit d698501b40
2 changed files with 10 additions and 3 deletions

View File

@ -375,23 +375,29 @@ String Esp8266::Send(const String& cmd, cstring expect, cstring expect2, uint ms
// 判断是否正在发送其它指令 // 判断是否正在发送其它指令
if(_Expect) if(_Expect)
{ {
#if NET_DEBUG
auto w = (WaitExpect*)_Expect; auto w = (WaitExpect*)_Expect;
// 大于一定时间的等待,不要堵塞其它任务发送数据
auto block = w->Timeout < 3000;
#if NET_DEBUG
net_printf("Esp8266::Send %d 正在发送 ", w->TaskID); net_printf("Esp8266::Send %d 正在发送 ", w->TaskID);
if(w->Command) if(w->Command)
w->Command->Trim().Show(false); w->Command->Trim().Show(false);
else else
net_printf("数据"); net_printf("数据");
net_printf(" %d 无法发送 ", task.ID); if(block)
net_printf(" %d 无法发送 ", task.ID);
else
net_printf(" %d 同时发送 ", task.ID);
cmd.Trim().Show(true); cmd.Trim().Show(true);
#endif #endif
return rs; if(block) return rs;
} }
// 在接收事件中拦截 // 在接收事件中拦截
WaitExpect we; WaitExpect we;
we.TaskID = task.ID; we.TaskID = task.ID;
we.Timeout = msTimeout;
// 数据不显示Command没有打开NET_DEBUG时也不显示 // 数据不显示Command没有打开NET_DEBUG时也不显示
//we.Command = &cmd; //we.Command = &cmd;
we.Result = &rs; we.Result = &rs;

View File

@ -10,6 +10,7 @@ public:
WaitHandle Handle; // 等待句柄 WaitHandle Handle; // 等待句柄
uint TaskID = 0; uint TaskID = 0;
uint Timeout = 0; // 超时时间
const String* Command = nullptr; const String* Command = nullptr;
String* Result = nullptr; String* Result = nullptr;
cstring Key1 = nullptr; cstring Key1 = nullptr;