Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

pcTaskGetName question

Posted by mitsoyba on April 5, 2017

FreeRTOS v9.0.0, tm4c123gh6pm MCU

Hi All,

I am trying to get a tasks name by using the pcTaskGetName function.

I tried from within the task with NULL as parameter and also from elsewhere with the tasks handle as a parameter, but i always get back a pointer to "main".

i use the following define as well:

INCLUDE_pcGetTaskName 1

Am i missing something?

Thanks in advance for your help.

Best regards, Dim


pcTaskGetName question

Posted by rtel on April 5, 2017

What do you mean you get a pointer to "main"? The string "main", or the main() function? Do you have task that is called "main"?

Are you calling this after the scheduler has been started?

The code for pcTaskGetName() is very simple, as below, step into it in the debugger to see what it is doing.

char *pcTaskGetName( TaskHandle_t xTaskToQuery )
{
TCB_t *pxTCB;

     /* If null is passed in here then the name of the calling task is being
     queried. */
     pxTCB = prvGetTCBFromHandle( xTaskToQuery );
     configASSERT( pxTCB );
     return &( pxTCB->pcTaskName[ 0 ] );
}

pcTaskGetName question

Posted by mitsoyba on April 5, 2017

Hi,

Sorry for not being clear about the pointer, its not the function but the string.

I call the function after the scheduler has started.

Offcourse i havent made another "main" function ;)

I will debug the project asap and let you know.

Thanks for the quick response.

Best regards, Dim


pcTaskGetName question

Posted by mitsoyba on April 6, 2017

Hi,

I did a debug session as you suggested and it seems that whatever handle i provide for the pcTaskGetName, i always get back the "main" string.

Currently, i call pcTaskGetName from within a task after the task scheduler has started.

Please see attached images.

Best regards, Dim

Attachments

img1.png (88839 bytes)
img2.png (96804 bytes)

pcTaskGetName question

Posted by heinbali01 on April 6, 2017

pcTaskGetName( NULL ) will return the name of the task that is currently active. So if you call pcTaskGetName( NULL ) from a task whose name is "main", it is logical that it returns that string.

Didn't you create your task with xTaskCreate( pvFunction, "main", xxx) ?

If the idle-task would call pcTaskGetName( NULL ), it would see "IDLE"

Or if your task would call pcTaskGetName( xIdleTaskHandle ), it would also receive the string "IDLE"

( NB. TaskHandle_t xIdleTaskHandle is declared static in tasks.c, so you can not easily try that )

Does that answer your question?


pcTaskGetName question

Posted by mitsoyba on April 6, 2017

Hi Hein,

Thanks for your quick response and help.

Actaully i found out that i was passing the wrong pointer to a function hence the problem.

Sorry for wasting your time!

Best regards, Dim


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists