Re: designing a message "bus"


Guy Morand
 

Hi Yshragai,

Have you looked at 'k_mbox' data structure? It seems you can set a destination thread or broadcast messages with 'K_ANY':
https://docs.zephyrproject.org/latest/kernel/services/data_passing/mailboxes.html

Hope this helps,
regards,

Guy

On 5/3/22 23:20, yshragai.firmware@... wrote:
Hi,
I'm wanting to design a firmware, for a small low-power embedded system, with an architecture that features a "bus" over which the firmware modules communicate. I'm wondering how to design this "bus".
Basically what I'm envisioning is modules sending messages over this bus that contain an address or module ID of some sort or another; the module that matches this address or ID would pick up the message off the bus.
One brute-force way to design this is a queue (such as a FIFO) per target module. This is not the most elegant or scalable solution, but it'll work... Is there a way to design this that's more scalable, and maybe even elegant?
I wish there were a mechanism in Zephyr by which a thread could subscribe to messages in a given queue not by sender ID (as is possible with a mailbox) but by some identifying characteristic of the message (e.g., by the value in the "info" field).
Thanks!
--
bytes at work
Technoparkstrasse 7
CH-8406 Winterthur
Switzerland

phone: +41 52 213 79 79

Join users@lists.zephyrproject.org to automatically receive all group messages.