首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在freeRTOS中向多脉冲接收端发送队列消息?

如何在freeRTOS中向多脉冲接收端发送队列消息?
EN

Stack Overflow用户
提问于 2019-12-28 17:02:27
回答 1查看 1.3K关注 0票数 1

我正在寻找一种在freeRTOS中使用队列广播消息的方法,我想出了不同的想法,但每个想法都有不同的问题。

我所拥有的:

  • 队列的项类型是一个带有属性的结构,用于指示消息是广播的还是特定任务的。
  • 将消息写入队列的广播任务。
  • 队列管理器任务,如果接收到任何新消息,它将查看队列,如果消息有目的地,则该任务将恢复该特定任务,如果是广播,则将恢复所有任务。
  • 对于接收者的任务,我想出了这样的想法:
代码语言:javascript
复制
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.

我仍然在考虑其他方法,比如为每个接收任务使用新队列或队列,但我还不确定哪种方法是最好的。我不知道还有什么其他的原因,即使不使用队列技术,也要广播消息。

我需要告诉你,这个计划不是为一个特定的项目。我只是尝试以不同的方式使用队列技术。我已经找到了其他关于广播消息的帖子,但这是为了解决一个特定的问题,他们不用队列技术就能解决这个问题。我只想把“这是一个广播消息”发送到队列中,所有接收者都可以读取它一次(就一次)。

谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-12-29 22:18:41

事件组是FreeRTOS中唯一的广播机制。您可以使用事件组来取消使用queue peek函数从队列中读取的所有任务,然后使用xEventGroupSync()来知道何时所有任务都读取了数据,因此数据应该被删除。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59513019

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档