From e65e103c6666bcf99eaaccb1cf7d98696d4ebc18 Mon Sep 17 00:00:00 2001 From: Barry Xu Date: Wed, 31 Mar 2021 12:57:24 +0800 Subject: [PATCH] Add rmw_publisher_wait_for_all_acked support Signed-off-by: Barry Xu --- rmw_cyclonedds_cpp/src/rmw_node.cpp | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/rmw_cyclonedds_cpp/src/rmw_node.cpp b/rmw_cyclonedds_cpp/src/rmw_node.cpp index 0aa6b681..b0245f08 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -2259,6 +2259,39 @@ rmw_ret_t rmw_publisher_assert_liveliness(const rmw_publisher_t * publisher) return RMW_RET_OK; } +rmw_ret_t rmw_publisher_wait_for_all_acked( + const rmw_publisher_t * publisher, + rmw_time_t wait_timeout) +{ + RMW_CHECK_ARGUMENT_FOR_NULL(publisher, RMW_RET_INVALID_ARGUMENT); + RMW_CHECK_TYPE_IDENTIFIERS_MATCH( + publisher, + publisher->implementation_identifier, + eclipse_cyclonedds_identifier, + return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); + + auto pub = static_cast(publisher->data); + if (pub == nullptr) { + RMW_SET_ERROR_MSG("The publisher is not a valid publisher."); + return RMW_RET_INVALID_ARGUMENT; + } + + dds_duration_t timeout = rmw_duration_to_dds(wait_timeout); + switch (dds_wait_for_acks(pub->enth, timeout)) { + case DDS_RETCODE_OK: + return RMW_RET_OK; + case DDS_RETCODE_BAD_PARAMETER: + RMW_SET_ERROR_MSG("The publisher is not a valid publisher."); + return RMW_RET_INVALID_ARGUMENT; + case DDS_RETCODE_TIMEOUT: + return RMW_RET_TIMEOUT; + case DDS_RETCODE_UNSUPPORTED: + return RMW_RET_UNSUPPORTED; + default: + return RMW_RET_ERROR; + } +} + rmw_ret_t rmw_publisher_get_actual_qos(const rmw_publisher_t * publisher, rmw_qos_profile_t * qos) { RMW_CHECK_ARGUMENT_FOR_NULL(publisher, RMW_RET_INVALID_ARGUMENT);