xTaskNotifyWait() not processing a specific notification

I have the code below

    if (xTaskNotifyWait(0, 0, &uiCurrentNotificationValue, portMAX_DELAY) == pdTRUE) 
        //notification received
        if (uiCurrentNotificationValue == NOTIF__PRINT_LABEL__LBL_UPLOADED)
            app_print_labelData.state = APP_PRINT_LABEL_STATE_STANDBY; 

Which is in a Switch statement which in turn is in a loop.
The program arrives at that point (I checked with the debugger) and then, as you can see the code keeps effectively looping inside that “case APP_PRINT_LABEL_WAITING_LABEL_UPLOAD:” block because nowhere in the code that state is changed. And I also double checked. It keeps looping in there.

To that task I send various DIFFERENT messages including the one below:


But it never gets processed, it keeps getting inside the IF brackets but never recognises the message NOTIF__PRINT_LABEL__LBL_UPLOADED

I assume that all other messages that I send are just read and purged/discarded by the xTaskNotifyWait() automatically even if I don’t do anything inside that. Is that correct?

Do I have perhaps to set/clear some flags?

Am I using the the xTaskNotifyWait() incorrectly?

Ultimately what I need to do is what I assumed above… To have that xTaskNotifyWait() discard all messages that have been sent to that task and are in the task queue until that specific one arrives.

Also, I am pretty sure I am not passing the wrong task pointer in the xTaskNotify(), but how can U double check?

Thank you

You can read this page to see how xTaskNotify works: xTaskNotify() RTOS task notification API documentation

In case of eSetBits, it will just set the specific bits. Therefore, the check should in your if should be:

if ((uiCurrentNotificationValue & NOTIF__PRINT_LABEL__LBL_UPLOADED) != 0 )


Thank you Gaurav!
That solved it.