我正在寻找一种在freeRTOS中使用队列广播消息的方法,我想出了不同的想法,但每个想法都有不同的问题。
我所拥有的:
1. if i used the receive function `xQueueReceive` only the first task in task-queue will read the message and remove it from queue and with this, the other tasks will not be able to read that broadcast message. in the other hand, it's the perfect why for directed message (message for a specific task).
2. if i use the peedk function `xQueuePeek` the message will never be removed from queue unless i use `xQueueReceive` which is kinda redundant (peek and receive in the same task, meeh, ugly coding) and i can't use any other delete function because it will remove the whole queue. but that will solve the message for a specific task, and to solve the broadcast message i need to set a priority for each receive task and only the task with the lowest priority will use `xQueueReceive` to remove that message from queue and all receive tasks will suspend themselves after peeking or reading so they don't read again the message (i'm not sure what to do about the queue manager task because i can't suspend it and it will keep notified about a new message in queue until the last task receive it), but the whole system will need to wait for that low priority task to run to remove that message and any new message received in that time, it will not be read in the real time.
我仍然在考虑其他方法,比如为每个接收任务使用新队列或队列,但我还不确定哪种方法是最好的。我不知道还有什么其他的原因,即使不使用队列技术,也要广播消息。
我需要告诉你,这个计划不是为一个特定的项目。我只是尝试以不同的方式使用队列技术。我已经找到了其他关于广播消息的帖子,但这是为了解决一个特定的问题,他们不用队列技术就能解决这个问题。我只想把“这是一个广播消息”发送到队列中,所有接收者都可以读取它一次(就一次)。
谢谢。
发布于 2019-12-29 22:18:41
事件组是FreeRTOS中唯一的广播机制。您可以使用事件组来取消使用queue peek函数从队列中读取的所有任务,然后使用xEventGroupSync()来知道何时所有任务都读取了数据,因此数据应该被删除。
https://stackoverflow.com/questions/59513019
复制相似问题