串口任务采用成员函数。

修正中断TS的一个BUG
This commit is contained in:
Stone 2016-06-13 14:59:22 +00:00
parent f03e134606
commit 005bd5bcef
3 changed files with 8 additions and 7 deletions

View File

@ -342,10 +342,10 @@ void SerialPort::OnRxHandler()
#pragma arm section code #pragma arm section code
void SerialPort::ReceiveTask(void* param) void SerialPort::ReceiveTask()
{ {
auto sp = (SerialPort*)param; //auto sp = (SerialPort*)param;
assert(sp, "串口 ReceiveTask param Error"); auto sp = this;
//!!! 只要注释这一行,四位触摸开关就不会有串口溢出错误 //!!! 只要注释这一行,四位触摸开关就不会有串口溢出错误
if(sp->Rx.Length() == 0) return; if(sp->Rx.Length() == 0) return;
@ -385,7 +385,8 @@ void SerialPort::Register(TransportHandler handler, void* param)
// 建立一个未启用的任务,用于定时触发接收数据,收到数据时开启 // 建立一个未启用的任务,用于定时触发接收数据,收到数据时开启
if(!_taskidRx) if(!_taskidRx)
{ {
_taskidRx = Sys.AddTask(ReceiveTask, this, -1, -1, "串口接收"); //_taskidRx = Sys.AddTask([](void* p){ ((SerialPort*)p)->ReceiveTask(); }, this, -1, -1, "串口接收");
_taskidRx = Sys.AddTask(&SerialPort::ReceiveTask, this, -1, -1, "串口接收");
_task = Task::Get(_taskidRx); _task = Task::Get(_taskidRx);
// 串口任务深度设为2允许重入解决接收任务内部调用发送然后又等待接收匹配的问题 // 串口任务深度设为2允许重入解决接收任务内部调用发送然后又等待接收匹配的问题
_task->MaxDeepth = 2; _task->MaxDeepth = 2;

View File

@ -83,7 +83,7 @@ private:
Task* _task; Task* _task;
uint _taskidRx; uint _taskidRx;
static void ReceiveTask(void* param); void ReceiveTask();
}; };
#endif #endif

View File

@ -407,8 +407,8 @@ TraceStack::TraceStack(cstring name)
TraceStack::~TraceStack() TraceStack::~TraceStack()
{ {
// 清空最后一个项目,避免误判 // 清空最后一个项目,避免误判
if(_TS_Len > 0) _TS[_TS_Len--] = ""; //if(_TS_Len > 0) _TS[--_TS_Len] = "";
//_TS->Pop(); _TS_Len--;
} }
void TraceStack::Show() void TraceStack::Show()