im notifying a task from different tasks … setting a bit for each notification (i’ve 32bits) so i can have 32 boolean messages from different tasks …
inside the notified task … im reading the notifications from various places like this
/*
* task that gets notifications from various tasks
*/
task_thread_notified(){
//stack stuff init
uint32_t ulNotificationValue;
while(1){
// long code
if (xTaskNotifyWait(0x0, 1<<0 , &ulNotificationValue, 10) == pdTrue){
if (ulNotificationValue & (1<<0)){
//do somthing
}
}
/// long code again
if (xTaskNotifyWait(0x0, 1<<1 , &ulNotificationValue, 10) == pdTrue){
if (ulNotificationValue & (1<<1)){
//do somthing else
}
}
}
}
my problem is that xTaskNotifyWait will update that index notification state to taskNOT_WAITING_NOTIFICATION … and the second xTasknotifyWait will never be read … is its waiting for the state to be taskNOTIFICATION_RECEIVED
in all other tasks im using the following: xTaskNotify(H_task_thread_notified, (1<<0) ,eSetValueWithOverwrite);
and on some other code/task xTaskNotify(H_task_thread_notified, (1<<1) ,eSetValueWithOverwrite);
so what is the best practice to use 32bit value to send 32 different msgs … and read them from different places inside a task …
Hi…
There are some delays inside the task…
Some of them are pure time delay done with vTaskDelay and some of them depend on other tasks …
For example in the task im waiting to fill a tank with water … so i do following:
xTaskNotify(hFillingTask, …)
And then somewhere else i need to make sure tank is full or timeout i do following
xTaskNotifyWait(0x0,(1<<0), unotifVal,timout)
Inside of the filling task of course i notify with 1<<0
Now because of the dalays … i need to implement xNotifyWait in various places and check if other tasks notified the current one …
I understand i can use semaphore and clear the bit my self … but i felt i can do everything with notification … its cleaner code …
I also can use indexed notification … but thats alot for what im trying to achieve i dont think im using the best practice …
My only problem is that reading notifications will set its state from recieved to pending …
The clearing of.a Notification is sort of part of the definition of them. The task was notified, and it goes away.
Maybe you should look at Event Groups, those can be set and left set until something explicitly clears it.