How to get the task handle by name?

wsghr2021
Posts: 5
Joined: Wed Jun 02, 2021 9:03 am

How to get the task handle by name?

Postby wsghr2021 » Wed Jun 02, 2021 9:33 am

I can't find xTaskGetHandle in ESP-IDF.
Is there any other API to implement the same function?
thx.

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: How to get the task handle by name?

Postby chegewara » 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

wsghr2021
Posts: 5
Joined: Wed Jun 02, 2021 9:03 am

Re: How to get the task handle by name?

Postby wsghr2021 » Thu Jun 03, 2021 12:48 am

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 .

Who is online

Users browsing this forum: Bing [Bot] and 87 guests