Task handle not recognised

Hi,
I am using xTaskNotifyFromISR() in this ISR callback function:

void CHANGE_NOTICE_B_Handler (void)
{
    //
    CHANGE_NOTICE_B_InterruptHandler();
    xTaskNotifyFromISR(xAPP_PRINTER_Tasks, 0x01, eSetBits);
}

and I have all the includes like this:

#include "configuration.h"
#include "definitions.h"
#include "app_printer.h"
#include "task.h"

and definition.h also has plenty of other includes as below:

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "peripheral/clk/plib_clk.h"
#include "peripheral/gpio/plib_gpio.h"
#include "peripheral/evic/plib_evic.h"
#include "driver/i2c/drv_i2c.h"
#include "system/time/sys_time.h"
#include "peripheral/i2c/master/plib_i2c2_master.h"
#include "peripheral/uart/plib_uart1.h"
#include "peripheral/tmr/plib_tmr2.h"
#include "system/console/sys_console.h"
#include "system/console/src/sys_console_uart_definitions.h"
#include "FreeRTOS.h"
#include "task.h"
#include "system/int/sys_int.h"
#include "osal/osal.h"
#include "system/debug/sys_debug.h"
#include "app_panel_io_exp.h"
#include "app_panel_exp_outputs.h"
#include "app_panel_exp_inputs.h"
#include "app_panel_exp_adc.h"
#include "app_printer.h"

But I get the errors further below which does not make sense…

Any ideas/suggestions?

Thank you

../src/config/default/interrupts.c: In function 'CHANGE_NOTICE_B_Handler':
In file included from ../src/third_party/rtos/FreeRTOS/Source/include/queue.h:40:0,
                 from ../src/config/default/osal/osal_freertos.h:57,
                 from ../src/config/default/osal/osal_definitions.h:27,
                 from ../src/config/default/osal/osal.h:80,
                 from ../src/config/default/driver/i2c/src/drv_i2c_local.h:52,
                 from ../src/config/default/driver/i2c/drv_i2c.h:1394,
                 from ../src/config/default/definitions.h:54,
                 from ../src/config/default/interrupts.c:53:
../src/config/default/interrupts.c:102:17: error: 'xAPP_PRINTER_Tasks' undeclared (first use in this function)
     xTaskNotify(xAPP_PRINTER_Tasks, 0x01, eSetBits);
                 ^
../src/third_party/rtos/FreeRTOS/Source/include/task.h:1854:78: note: in definition of macro 'xTaskNotify'
 #define xTaskNotify( xTaskToNotify, ulValue, eAction ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL )
                                                                              ^
../src/config/default/interrupts.c:102:17: note: each undeclared identifier is reported only once for each function it appears in
     xTaskNotify(xAPP_PRINTER_Tasks, 0x01, eSetBits);
                 ^
../src/third_party/rtos/FreeRTOS/Source/include/task.h:1854:78: note: in definition of macro 'xTaskNotify'
 #define xTaskNotify( xTaskToNotify, ulValue, eAction ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL )
                                                                              ^
make[2]: *** [build/default/production/_ext/1171490990/interrupts.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

I just noticed that the task handle is defined in tasks.c (instead of a task.h):

/* Handle for the APP_PRINTER_Tasks. */
TaskHandle_t xAPP_PRINTER_Tasks;

And that code is auto generated so I don’t want to mess with the structure.

How can I make that handle visible in another file?
Do I just define it as extern in the new file? Or are there other/better ways to do it?

Thank you

This is just telling you that use used an undeclared identifier - I don’t think that is anything to do with FreeRTOS.

I just noticed that the task handle is defined in tasks.c (instead of a task.h):

/* Handle for the APP_PRINTER_Tasks. */
TaskHandle_t xAPP_PRINTER_Tasks;

That code is not from FreeRTOS/Source/include/task.h. Do you have two header files called task.h in your path?

Thank you Richard,
Yes, it is not from task.h it is from task.c
That was my second point. Being the task handle defined in the task.c (i.e. in the source code not in the header), what is the correct way to make it visible in all other files?

It works by defining it as extern in the other files, but I was wondering if I should do in other ways?

Thank you

TaskHandle_t is opaque to the application is defined in task.h: FreeRTOS-Kernel/task.h at main · FreeRTOS/FreeRTOS-Kernel · GitHub

Thanks.

Thank you Gaurav,
what do you mean by “opaque” to the application?

I was referring to the handle variable definition. The handle variable xAPP_PRINTER_Tasks is defined in the task.c but I need to pass it to a xTaskNotifyFromISR() which is in another .c file. So unless I declare that handle variable as extern in my other file, it does not see it.

And I was wondering if declaring it as extern in the other file/s is the right way to do it.

Thank you

Yes, that is the right way to do it.

Thanks.

Thank you Gaurav and Richard :slight_smile: