Hello Dear friends.
The project I’m working on includes multiple sensors that send data over the serial port. So far I have used a global circular list for each sensor and then parsed data received. which means data are written to list on interrupt and processed on a separate task. I know that there a couple of methods that can send that between tasks like a queue, semaphore, and message buffer. But the main problem is only one queue, semaphore, or message buffer can be implemented between two tasks. I wonder if there are any methods that can be used so that each parser task can separately send its data to the main task for representation. The matter is a single queue can not be used since the throughput of data is too high, which in case of limited buffer size, it make the program to be stumbled up upon data reception of data. As far as I have studied, “only one” queue can be used on each task. Please lit me up. Any matchwood would be appreciated.
Any help would be appreciated.
Hello Dear friends.
There is no problem using multiple queue. The main issue is that a task can generally only wait for a single thing at a time.
One option is the QueueSet, which creates a Queue that keeps track of which of the queue put into it have data, and then the receiving task can wait on the QueueSet, and then get the data from whichever queue has the oldest data to process.
Thank you for your reply.
The example for Queset is not really clear. by which I mean there is no example on how to push data to queue, but there is code for popping data out from queues. Moreover, no way was shown on how to add this queue set to the tasks so they can communicate each other.
Furthermore, I’m looking for separate access for each queue here or in my tongue, data parsed in each task.
The Queues in a QueueSet are sent to just like any ordinary queue. Typically it is used when one receiving task needs to handle several different types of messages with different sizes, so you setup a queue set with a queue for each type of messages, and the QueueSet gives the receiving task the ability to wait for a message from any to them.
Each of your sending tasks could use its own queue to send to the main task, that are all combined into a queue set so the main task can wait for data from any of them.
Is there any example code with the specifications you mentioned above?
Did you see this page? Pend on multiple RTOS objects It also contains info on how to achieve the same without using a queue set. You can also look at some of the test code: FreeRTOS/QueueSet.c at master · FreeRTOS/FreeRTOS · GitHub
I guess you already found the related API docs like Pend (or block) on multiple RTOS queues and semaphores in a set with examples.
As Richard already tried to explain there is no extra code demonstrating sending some data via a queue even when added to a queue set because there is no difference.
Just use e.g. xQueueSend with the individual queue handles.
A queue set is a mechanism to block on/receive from multiple queues. Just feed the individual queues as usual/documented.
Thank you all
I will try more to understand the mechanism .
Yet another way is to have the task do a NotifyWait and then have all the event generators do a corresponding NotifyGive when they make new data available. Then the awakened task needs to check all the event generators to see which ones(s) woke it up. We use this mechanism when we don’t want to use a FreeRTOS queue to store the events, for example when the event is receipt of a single character so a ring buffer is more efficient than a queue.