nuttx-apps/include
Jorge Guzman ee20ddd0ba system/zbus: Port the Zephyr zbus message bus to NuttX
Port of the Zephyr RTOS zbus (many-to-many message bus with typed
channels and decoupled observers), built entirely on native NuttX
primitives and preserving the original declarative API
(ZBUS_CHAN_DEFINE, ZBUS_LISTENER_DEFINE, ZBUS_SUBSCRIBER_DEFINE, ...).

Features: listeners (synchronous callbacks), subscribers (queue of
channel references), message subscribers (ordered message copies),
async listeners (callback on a dedicated task), runtime observers,
per-observation notification masks, observer enable/disable, message
validators, channel user data, publish statistics, lookup by
name/numeric id and channel/observer iteration.

Mapping to NuttX primitives:
- Channel/observer registration: link-time iterable sections
  (include/nuttx/iterable_sections.h); the observers of a channel are
  named after their position in the definition, so the linker sorts the
  notification order, and the declarative macros are built on
  nuttx/macro.h (CONCATENATE, FOREACH_ARG and the FOREACH_IDX_ARG added
  in a companion nuttx commit) rather than on a private macro engine.
  Notification masks live in .bss with their initial value preserved in
  ROM and applied on lazy init.
- Channel lock: sem_t (enable CONFIG_PRIORITY_INHERITANCE instead of
  the Zephyr priority-boost/HLP); timeouts are computed with the
  clock_timespec_* helpers from nuttx/clock.h.
- Subscriber queues: kernel message queues (file_mq_*) opened lazily
  via pthread_once, usable from any task; mq payload copying replaces
  the Zephyr net_buf machinery entirely.
- Async listeners: one task per listener (task_create, priority and
  stack size configurable) blocking on the listener queue; a task
  rather than a pthread so it outlives the first API caller.
- Timeouts: milliseconds with CLOCK_MONOTONIC deadlines
  (ZBUS_NO_WAIT/ZBUS_FOREVER).

Includes a runnable example (examples/zbus, CONFIG_EXAMPLES_ZBUS) and a
cmocka test suite (testing/zbus, CONFIG_TESTING_ZBUS) covering the full
API: 17/17 tests passing on linum-stm32h753bi hardware, including
multi-channel index grouping, mask semantics, runtime observer error
paths, notification order (the observers of a channel run in the order
they are listed, and an observation bound with ZBUS_CHAN_ADD_OBS() runs
after all of them), queue overflow/timeout semantics, async listener
bursts,
bit-exact float/double payload delivery across every observer type
(sensor-style messages with a float-math validator) and an
interrupt-driven publisher (kernel timer interrupt -> signal -> sampling
thread -> zbus_chan_pub, the recommended pattern for interrupt sources).

Requirements: FLAT build; CONFIG_MQ_MAXMSGSIZE >= pointer size +
CONFIG_ZBUS_MSG_SUBSCRIBER_MAX_MSG_SIZE for message subscribers; board
linker script including <nuttx/linker/common-rom.ld> or the generic
CONFIG_ITERABLE_SECTIONS_LINKER_INSERT mode.

Not ported: multi-domain proxy agent (experimental upstream); publishing
from interrupt handlers (userspace library: hand the data to a thread).

Documentation lives in the nuttx repository
(Documentation/applications/system/zbus).

Assisted-by: Claude Code
Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
2026-09-21 18:46:31 -03:00
..
audioutils include: migrate to SPDX identifier 2024-12-19 15:25:28 +08:00
builtin include: migrate to SPDX identifier 2024-12-19 15:25:28 +08:00
canutils style: Fix coding style violations in nuttx-apps 2026-01-12 00:54:48 +08:00
crypto/controlse include: migrate to SPDX identifier 2024-12-19 15:25:28 +08:00
fsutils !fsutils/passwd: Replace TEA with PBKDF2-HMAC-SHA256 2026-07-22 17:21:22 +08:00
graphics include/debug.h: Use <nuttx/debug.h> in apps 2026-04-11 10:39:27 -03:00
industry style: Fix coding style violations in nuttx-apps 2026-01-12 00:54:48 +08:00
interpreters include: migrate to SPDX identifier 2024-12-19 15:25:28 +08:00
logging/nxscope logging/nxscope: add UDP transfer interface 2026-03-18 12:43:50 -03:00
lte include: migrate to SPDX identifier 2024-12-19 15:25:28 +08:00
modbus include: migrate to SPDX identifier 2024-12-19 15:25:28 +08:00
netutils !fsutils/passwd: Replace TEA with PBKDF2-HMAC-SHA256 2026-07-22 17:21:22 +08:00
nshlib nshlib: Add stderr redirection support 2026-01-27 03:14:00 +08:00
nxmodbus modbus: add nxmodbus 2026-04-20 12:45:17 -03:00
platform include: migrate to SPDX identifier 2024-12-19 15:25:28 +08:00
system system/zbus: Port the Zephyr zbus message bus to NuttX 2026-09-21 18:46:31 -03:00
testing apps/unity: Add printf configuration 2025-08-07 11:21:57 +08:00
wasm include: migrate to SPDX identifier 2024-12-19 15:25:28 +08:00
wireless include: migrate to SPDX identifier 2024-12-19 15:25:28 +08:00
.gitignore audioutils/morsey: Add the Morsey library 2026-07-21 05:46:11 -03:00