Page 1 of 1

How to get the task handle by name?

Posted: Wed Jun 02, 2021 9:33 am
by wsghr2021
I can't find xTaskGetHandle in ESP-IDF.
Is there any other API to implement the same function?
thx.

Re: How to get the task handle by name?

Posted: Wed Jun 02, 2021 10:34 am
by chegewara
https://www.freertos.org/a00021.html#xTaskGetHandle
NOTE: This function takes a relatively long time to complete and should only be called once for each task. Once the handle of a task has been obtained it can be stored locally for re-use.

INCLUDE_xTaskGetHandle must be set to 1 in FreeRTOSConfig.h for xTaskGetHandle() to be available.
It seems it is not enabled in esp-idf, but if you really need something like that then you can adapt this code:
https://www.freertos.org/uxTaskGetSystemState.html

Re: How to get the task handle by name?

Posted: Thu Jun 03, 2021 12:48 am
by wsghr2021
chegewara wrote:
Wed Jun 02, 2021 10:34 am
https://www.freertos.org/a00021.html#xTaskGetHandle
NOTE: This function takes a relatively long time to complete and should only be called once for each task. Once the handle of a task has been obtained it can be stored locally for re-use.

INCLUDE_xTaskGetHandle must be set to 1 in FreeRTOSConfig.h for xTaskGetHandle() to be available.
It seems it is not enabled in esp-idf, but if you really need something like that then you can adapt this code:
https://www.freertos.org/uxTaskGetSystemState.html
Got it, thanks a lot .