FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [March 2014 Threads] Hoe to get the Task Number?Posted by alainm3 on March 15, 2014 Inside vApplicationStackOverflowHook(), I need to get the Task number for error report.
How can I get it from the xTaskHandle?
Thanks, Alain
Hoe to get the Task Number?Posted by rtel on March 15, 2014 You can use the function:
UBaseTypet uxTaskGetTaskNumber( TaskHandlet xTask );
I'm not sure if that is documented as it is intended for internal and tracing use really. configUSETRACEFACILITY must be set to 1 in FreeRTOSConfig.h.
Note if the stack has overflowed then you may find the task handle passed into the hook function is corrupt. In which case you can use the pxCurrentTCB variable to get the handle instead, but you will have to declare it as an extern inside your hook function to make it available.
Finally you could also keep a track of the number of the task that is currently running by defining a trace macro (assuming you are not using the trace macros for anything else). To do that declare a variable in your main.c (or somewhere else suitable) as per:
UBaseType_t uxCurrentTaskNumber = 0;
Then at the bottom of FreeRTOSConfig.h add:
extern UBaseType_t uxCurrentTaskNumber;
#define traceTASK_SWITCHED_IN() uxCurrentTaskNumber = pxCurrentTCB->uxTaskNumber;
then in your hook you can just look at the uxCurrentTaskNumber variable.
Regards.
Hoe to get the Task Number?Posted by alainm3 on March 16, 2014 Hi, thanks for the promp reply :)
the third option is probably the simplest... BUT...
IT ONLY WORKS with pxCurrentTCB->uxTCBNumber !!!
uxTaskNumber doesn't seem to be updated and uxTCBNumber is what I get in
pxTaskStatusArray (which serves as reference anyway...)
I has to change UBaseType -> portBASETYPE -> long
I am using 7.6.0 version because I expect trouble with LWIP. And also
because portBASETYPE is defined inside portmacro.h wich is not known to
my main.c
NOTE: It's unfortunate that tskTaskControlBlock is defined only inside
tasks.c, it would be much easier to use in tasks.h. Maybe not safe...
the world isn't perfect...
thanks,
Alain
Em 15-03-2014 11:54, Real Time Engineers ltd. escreveu:
>
> You can use the function:
>
> UBaseTypet uxTaskGetTaskNumber( TaskHandlet xTask );
>
> I'm not sure if that is documented as it is intended for internal and
> tracing use really. configUSETRACEFACILITY must be set to 1 in
> FreeRTOSConfig.h.
>
> Note if the stack has overflowed then you may find the task handle
> passed into the hook function is corrupt. In which case you can use
> the pxCurrentTCB variable to get the handle instead, but you will have
> to declare it as an extern inside your hook function to make it available.
>
> Finally you could also keep a track of the number of the task that is
> currently running by defining a trace macro (assuming you are not
> using the trace macros for anything else). To do that declare a
> variable in your main.c (or somewhere else suitable) as per:
>
> ||
>
>
> UBaseTypet uxCurrentTaskNumber = 0;
>
> Then at the bottom of FreeRTOSConfig.h add:
>
> ||
>
>
> extern UBaseTypet uxCurrentTaskNumber;
>
>
> define traceTASKSWITCHEDIN() uxCurrentTaskNumber =
> pxCurrentTCB->uxTaskNumber;
>
> then in your hook you can just look at the uxCurrentTaskNumber variable.
>
> Regards.
>
> ------------------------------------------------------------------------
>
> Hoe to get the Task Number?
> https://sourceforge.net/p/freertos/discussion/382005/thread/77ed94e2/?limit=25#b2fe
>
> ------------------------------------------------------------------------
>
> Sent from sourceforge.net because you indicated interest in
> https://sourceforge.net/p/freertos/discussion/382005/
>
> To unsubscribe from further messages, please visit
> https://sourceforge.net/auth/subscriptions/
>
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|