- This topic has 0 replies, 1 voice, and was last updated 1 month, 2 weeks ago by
Logan Moon.
-
AuthorPosts
-
February 6, 2025 at 9:29 pm #16768
(This message was transferred over from our old forum)
Posted August 19, 2015
By Todd DeBoer
[hr]
On 03/04/2010 wella asked, “I think, there is an error in the function UEZTaskGetCurrent.T_uezTask UEZTaskGetCurrent(void)
{
T_uezTask h;
TUInt32 index = 0;
T_uezError found;
xTaskHandle currentTask;
xTaskHandle task;// TBD: This is slow!
// Get the FreeRTOS handle
currentTask = xTaskGetCurrentTaskHandle();
do {
found = uEZHandleFindOfType(UEZ_HANDLE_TASK, &h, &index);// Didn’t find task? Return 0
if (found != UEZ_ERROR_NONE)
return 0;uEZHandleGet(h, 0, 0, 0, (TUInt32 *)&task);
if (task == currentTask)
return h;
error:——————– } while (found);————return 0;
}If some UEZ_HANDLE_TASK is found, the found is UEZ_ERROR_NONE, 0 numerically. So that if the task is not first created(registered) it always return 0. I am suggesting the patch below, just only do it in the infinite loop.
Martin
————solution—————————–
T_uezTask UEZTaskGetCurrent(void)
{
T_uezTask h;
TUInt32 index = 0;
T_uezError found;
xTaskHandle currentTask;
xTaskHandle task;// TBD: This is slow!
// Get the FreeRTOS handle
currentTask = xTaskGetCurrentTaskHandle();
do {
found = uEZHandleFindOfType(UEZ_HANDLE_TASK, &h, &index);// Didn’t find task? Return 0
if (found != UEZ_ERROR_NONE)
return 0;uEZHandleGet(h, 0, 0, 0, (TUInt32 *)&task);
if (task == currentTask)
return h;
} while (ETrue);return 0;
}”
[hr]
(Follow up post)Answered:
I found this one myself and fixed it this way (I should have posted this sooner):
T_uezTask UEZTaskGetCurrent(void)
{
T_uezTask h;
TUInt32 index = 0;
T_uezError found;
xTaskHandle currentTask;
xTaskHandle task;// TBD: This is slow!
// Get the FreeRTOS handle
currentTask = xTaskGetCurrentTaskHandle();
do {
found = uEZHandleFindOfType(UEZ_HANDLE_TASK, &h, &index);// Didn’t find task? Return 0
if (found != UEZ_ERROR_NONE)
return 0;uEZHandleGet(h, 0, 0, 0, (TUInt32 *)&task);
if (task == currentTask) {
UEZAssert(uEZHandleGetType(h) == UEZ_HANDLE_TASK);
return h;
}
} while (!found);return 0;
}— Effectively the same as ETrue in the while.
I’m going to change that to ETrue to save a few bytes.
-
AuthorPosts
- You must be logged in to reply to this topic.