nuttx-apps/testing
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
..
arch apps/testing: move himem_test,mtetest and x86-64-ABI folders to the new arhc folder 2025-01-20 17:48:48 +08:00
cmocka cmake: Use NUTTX(_DIR/_BINARY_DIR) instead of CMAKE(_SOURCE_DIR/BINARY_DIR) 2026-08-09 10:43:01 -03:00
crypto !fsutils/passwd: Replace TEA with PBKDF2-HMAC-SHA256 2026-07-22 17:21:22 +08:00
cxx apps: Fix minor issues for latest toolchains 2026-01-23 10:00:52 +08:00
cxx-oot-build testing/cxx-oot-build: Exclude cxx-oot-build in CMake projects. 2025-10-15 14:34:32 +08:00
drivers testing/drivertest: add sensor watchdog regression test. 2026-09-18 21:10:56 +08:00
enet apps/testing: add cmock_test for enet in order to test send and receive pkt 2025-12-29 22:30:56 +08:00
fff cmake: Use NUTTX(_DIR/_BINARY_DIR) instead of CMAKE(_SOURCE_DIR/BINARY_DIR) 2026-08-09 10:43:01 -03:00
fs testing/ostest: Split the fork test into vfork and fork. 2026-08-14 07:46:54 -03:00
libc apps: replace atomic_fetch_xxx with atomic_xxx 2026-08-24 20:10:37 +08:00
ltp testing/ostest: Split the fork test into vfork and fork. 2026-08-14 07:46:54 -03:00
mm cmake: Use NUTTX(_DIR/_BINARY_DIR) instead of CMAKE(_SOURCE_DIR/BINARY_DIR) 2026-08-09 10:43:01 -03:00
nettest testing/nettest: add SO_TIMESTAMPING cmocka test 2026-09-21 16:26:06 +08:00
nuts testing/nuts: NuttX Unit Test Selection (NUTS) application. 2025-12-28 10:28:14 +08:00
ostest testing/ostest: accept -ENOENT from work_cancel() for unqueued work 2026-09-17 09:40:21 -03:00
sched testing/sched: fix off-by-one sample count in timerjitter 2026-07-11 12:31:24 -03:00
sig_sp_test testing/sig_sp_test: add test for SP context restore on signal return 2026-06-22 10:21:40 -03:00
testsuites fs: rename PSEUDOFS_SOFTLINKS to FS_LINKS 2026-08-27 13:31:34 +08:00
unity cmake: Use NUTTX(_DIR/_BINARY_DIR) instead of CMAKE(_SOURCE_DIR/BINARY_DIR) 2026-08-09 10:43:01 -03:00
zbus system/zbus: Port the Zephyr zbus message bus to NuttX 2026-09-21 18:46:31 -03:00
.gitignore Ensure all source code end with one and only one newline 2020-02-09 08:14:49 -06:00
CMakeLists.txt testing/cxx-oot-build: Exclude cxx-oot-build in CMake projects. 2025-10-15 14:34:32 +08:00
Make.defs testing: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00
Makefile testing: migrate to SPDX identifier 2024-12-30 18:02:50 +08:00