This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC2538:请介绍在 SampleLight 示例上创建新任务

Guru**** 2559110 points
Other Parts Discussed in Thread: Z-STACK

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/zigbee-thread-group/zigbee-and-thread/f/zigbee-thread-forum/694400/cc2538-please-introduce-create-new-task-on-samplelight-example

器件型号:CC2538
Thread 中讨论的其他器件:Z-stack

我使用 Z-Stack 3.0.1、

请介绍在 SampleLight 示例上创建新任务。

------

之前、我尝试了以下步骤:

-在 tasksArr[]中添加任务

const pTaskEventHandlerFn tasksArr[]={
macEventLoop、
NWK_EVENT_LOOP、
。
。
my_task_event_loop
} 

- osalInitTasks()中的初始化任务

void osalInitTasks( void ){

uint8 taskID = 0;

tasksEvents =(uint16 *) osal_mem_alloc (sizeof (uint16)* tasksCnt);
OSAL_memset (tasksEvents、0、(sizeof (uint16)* tasksCnt));

macTaskInit( taskID++);
NWK_INIT( taskID++);
。
。
。
BDB_Init( taskID++);
zclSampleLight_Init( taskID++);

my_task_Init( taskID );
}

void my_task_Init(uint8 task_id)
{
//无
}

uint16 my_task_event_loop (uint8 task_id、uint16事件)

{

//我的代码过程

返回事件;

} 

然后 、程序不会进入我的任务。  谢谢、请向我介绍一下。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    您必须创建自己的任务事件、并使用 osal_set_event 将事件发送到相关任务 ID 以触发 my_task_event_loop。
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    YK 所讨论的一个示例是 SAMPLELIGHT_LEVEL_CTRL_EVT,在 zcl_samplelight.h 中定义为0x02,并使用 osal_start_timerEx (zclSampleLight_TaskID、SAMPLELIGHT_LEVEL_CTRL_EVT,100)进行设置;在 zcl_samplelight.c 的多个函数中 这还表明、您需要创建一个模糊的 zclSampleLight_TaskID、该 ID 在 my_task_Init 中设置为 task_id。

    此致、
    Ryan
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    我有疑问
    1.在 my_task_Init 中一次性设置 OSAL_start_timerEx (),如果在 my_task_event_loop return event^event 中,我的任务将不再工作。
    为什么会这样呢?
    2.如何在 my_task_event_loop 中延迟?
    3.持续时间节拍时间 my_task_event_loop?
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    在 SampleSwitch OTA 示例中、OTA 具有自己的任务 ID 和事件循环。 我建议您对其进行研究、以了解如何添加新的任务事件循环。
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    谢谢。
    现在、我使用 osal_start_reload 作为任务中调用事件的延迟。 正常工作