diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2015-04-27 22:33:32 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2015-04-27 22:33:32 +0200 |
commit | f56efaf149807cbdc559a88df1abcf9bb13b9364 (patch) | |
tree | 7bf56e57c71bcfedc47a7af9be4bab290beb21da /src/modules/uORB | |
parent | 8595c734e646f22226672e0e06b6c38e0d80cb20 (diff) | |
parent | bd1c3363df44170523c68fd87ee19f2582a5e8fc (diff) | |
download | px4-firmware-f56efaf149807cbdc559a88df1abcf9bb13b9364.tar.gz px4-firmware-f56efaf149807cbdc559a88df1abcf9bb13b9364.tar.bz2 px4-firmware-f56efaf149807cbdc559a88df1abcf9bb13b9364.zip |
Merge branch 'master' into stablestable
Diffstat (limited to 'src/modules/uORB')
-rw-r--r-- | src/modules/uORB/uORB.cpp | 20 | ||||
-rw-r--r-- | src/modules/uORB/uORB.h | 9 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/modules/uORB/uORB.cpp b/src/modules/uORB/uORB.cpp index b4f81d429..d531c6b0b 100644 --- a/src/modules/uORB/uORB.cpp +++ b/src/modules/uORB/uORB.cpp @@ -41,6 +41,7 @@ #include <drivers/device/device.h> #include <sys/types.h> +#include <sys/stat.h> #include <stdint.h> #include <stdbool.h> #include <string.h> @@ -1196,6 +1197,25 @@ node_open(Flavor f, const struct orb_metadata *meta, const void *data, bool adve } // namespace +int +orb_exists(const struct orb_metadata *meta, int instance) +{ + /* + * Generate the path to the node and try to open it. + */ + char path[orb_maxpath]; + int inst = instance; + int ret = node_mkpath(path, PUBSUB, meta, &inst); + + if (ret != OK) { + errno = -ret; + return ERROR; + } + + struct stat buffer; + return stat(path, &buffer); +} + orb_advert_t orb_advertise(const struct orb_metadata *meta, const void *data) { diff --git a/src/modules/uORB/uORB.h b/src/modules/uORB/uORB.h index 44dc6614f..a8b19d91f 100644 --- a/src/modules/uORB/uORB.h +++ b/src/modules/uORB/uORB.h @@ -319,6 +319,15 @@ extern int orb_check(int handle, bool *updated) __EXPORT; extern int orb_stat(int handle, uint64_t *time) __EXPORT; /** + * Check if a topic has already been created. + * + * @param meta ORB topic metadata. + * @param instance ORB instance + * @return OK if the topic exists, ERROR otherwise with errno set accordingly. + */ +extern int orb_exists(const struct orb_metadata *meta, int instance) __EXPORT; + +/** * Return the priority of the topic * * @param handle A handle returned from orb_subscribe. |