From fbe5ef6087fa6ff9628c5faccbb4974a72f44c25 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 30 Aug 2015 00:12:33 +0200 Subject: [PATCH] uORB: Provide used group count --- src/modules/uORB/uORB.cpp | 14 ++++++++++++++ src/modules/uORB/uORB.h | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/src/modules/uORB/uORB.cpp b/src/modules/uORB/uORB.cpp index d292628be0..c8920607ac 100644 --- a/src/modules/uORB/uORB.cpp +++ b/src/modules/uORB/uORB.cpp @@ -260,6 +260,20 @@ int orb_exists(const struct orb_metadata *meta, int instance) return uORB::Manager::get_instance()->orb_exists(meta, instance); } +/** + * Get the number of published instances of a topic group + * + * @param meta ORB topic metadata. + * @return The number of published instances of this topic + */ +int orb_group_count(const struct orb_metadata *meta) +{ + unsigned group_count = 0; + while (!uORB::Manager::get_instance()->orb_exists(meta, group_count++)) {}; + + return group_count; +} + /** * Return the priority of the topic * diff --git a/src/modules/uORB/uORB.h b/src/modules/uORB/uORB.h index 7b40cff219..c887925fcf 100644 --- a/src/modules/uORB/uORB.h +++ b/src/modules/uORB/uORB.h @@ -328,6 +328,14 @@ extern int orb_stat(int handle, uint64_t *time) __EXPORT; */ extern int orb_exists(const struct orb_metadata *meta, int instance) __EXPORT; +/** + * Get the number of published instances of a topic group + * + * @param meta ORB topic metadata. + * @return The number of published instances of this topic + */ +extern int orb_group_count(const struct orb_metadata *meta) __EXPORT; + /** * Return the priority of the topic *