How to get info about the sending task from the data in freertos

I am a newbie to FreeRTOS and STM32. And I am working on a project which needs sending data from one task to another. But the receiving task needs to get the info about which task sent the data, because there are multiple tasks in my program. is there any way to get info about sending task from the receiving data in another task in freertos?? Thanks in advance

How to get info about the sending task from the data in freertos

If yoou send a struct as a message, you can place in it a field for who the sender was, and have the sender fill it out before sending.

How to get info about the sending task from the data in freertos

Thank You Richard…

How to get info about the sending task from the data in freertos

One other thing that I thought of after answering, to point out one thing that sometime people make a mistake on. If you have in your design several tasks, like A, B, and C, each sending a message to task D, and then waiting for an answer back before continuing, then ‘task D’ might not be best implemented as a task, but might just be a subroutine that tasks A, B, and C call, which might use a mutex if it should only be doing 1 thing at a time. This also automatically handle a priority issue that if C was a high priority task that needs its answer fast, but A can take its time, then as an independant task, D would need to be adjusting its execution priority based on whose work it is doing, and wouldn’t know that if C makes a request while it is doing A’s work, it needs to raise its priority. A Mutex would handle much of this operation. Second, even if making D a seperate task does become the final solution, a good implementation method still is for tasks A, B, and C to call a function in tasks D’s implementation file, and let that function deal with the transfer of information and return the results. This encapsulates the implementation decision so if you change your mind later, it is simpler to do.

How to get info about the sending task from the data in freertos

Maybe the daemon task startup hook could help too? See the last section on this page: https://www.freertos.org/a00016.html