xTaskNotifyWait update pulNotificationValue always?

I want test behavior of xTaskNotifyWaitIndexed. Does xTaskNotifyWaitIndexed save task notification to pulNotificationValue even if xTaskNotifyWaitIndexed returns false (e.g. no notify in task)?

My test proj is for Arduino. I use FreeRTOS port. Prog says to serial monitor:
ulNotifiedValue=3
ulNotifiedValue=0

So looks like xTaskNotifyWaitIndexed updates pulNotificationValue even if no notify will be got. It looks unlogical for me. I can’t believe to my eyes. I waited that pulNotificationValue will be the same if no new notify.

void mainTask(void *pvParameters){
xTaskNotify(TaskOut1_Handler, 3, eSetValueWithOverwrite);
while(1);
}

void TaskOut1(void *pvParameters){
uint32_t ulNotifiedValue= 0;
xTaskNotifyWaitIndexed(0, 0x00, ULONG_MAX, &ulNotifiedValue, portMAX_DELAY);
Log.print(“ulNotifiedValue=”);
Log.println(ulNotifiedValue);
xTaskNotifyWaitIndexed(0, 0x00, ULONG_MAX, &ulNotifiedValue, 0);
vTaskDelay( 2000 / portTICK_PERIOD_MS ); // wait for one second
Log.print(“ulNotifiedValue=”);
Log.println(ulNotifiedValue);
while(1);
}
xTaskNotifyWaitIndexed_pulNotificationValue.cpp (1.6 KB)

The notification value is always copied - FreeRTOS-Kernel/tasks.c at main · FreeRTOS/FreeRTOS-Kernel · GitHub

As described here, you should use the return value to determine whether or not a notification was received:


    pdTRUE if a notification was received, or a notification was already pending when xTaskNotifyWait() was called.

    pdFALSE if the call to xTaskNotifyWait() timed out before a notification was received. 

Thanks.

1 Like

May be doc
"Used to pass out the RTOS task’s notification value. The value copied to *pulNotificationValue is the RTOS task’s notification value as it was before any bits were cleared due to the ulBitsToClearOnExit setting.

If the notification value is not required then set pulNotificationValue to NULL. "

should be rewritten to

"Used to pass out the RTOS task’s notification value. The value copied to pulNotificationValue is the RTOS task’s current notification value as it was before any bits were cleared due to the ulBitsToClearOnExit setting. The value is copied to pulNotificationValue even xTaskNotifyWaitIndexed returns pdFALSE.

If the notification value is not required then set pulNotificationValue to NULL. "

?