From 095c03cb9c0eabce1449823f6eedf15f872b4b91 Mon Sep 17 00:00:00 2001 From: Ivan Santiago Paunovic Date: Fri, 5 Jun 2020 18:26:23 -0300 Subject: [PATCH 1/3] Add support to message lost event Signed-off-by: Ivan Santiago Paunovic --- rmw_cyclonedds_cpp/src/rmw_node.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/rmw_cyclonedds_cpp/src/rmw_node.cpp b/rmw_cyclonedds_cpp/src/rmw_node.cpp index fe64263be..06a4ac608 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -2458,6 +2458,7 @@ static const std::unordered_map mask_map{ {RMW_EVENT_OFFERED_DEADLINE_MISSED, DDS_OFFERED_DEADLINE_MISSED_STATUS}, {RMW_EVENT_REQUESTED_QOS_INCOMPATIBLE, DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS}, {RMW_EVENT_OFFERED_QOS_INCOMPATIBLE, DDS_OFFERED_INCOMPATIBLE_QOS_STATUS}, + {RMW_EVENT_MESSAGE_LOST, DDS_SAMPLE_LOST_STATUS | DDS_SAMPLE_REJECTED_STATUS}, }; static bool is_event_supported(const rmw_event_type_t event_t) @@ -2566,6 +2567,26 @@ extern "C" rmw_ret_t rmw_take_event( } } + case RMW_EVENT_MESSAGE_LOST: { + auto ei = static_cast(event_info); + auto sub = static_cast(event_handle->data); + dds_sample_lost_status_t st1; + dds_sample_rejected_status_t st2; + if (dds_get_sample_lost_status(sub->enth, &st1) < 0) { + *taken = false; + return RMW_RET_ERROR; + } + if (dds_get_sample_rejected_status(sub->enth, &st2) < 0) { + *taken = false; + return RMW_RET_ERROR; + } + ei->total_count = static_cast(st1.total_count + st2.total_count); + ei->total_count_change = + static_cast(st1.total_count_change + st2.total_count_change); + *taken = true; + return RMW_RET_OK; + } + case RMW_EVENT_LIVELINESS_LOST: { auto ei = static_cast(event_info); auto pub = static_cast(event_handle->data); From 30909a4f4ab65f5571acfc085eb24e72ae299546 Mon Sep 17 00:00:00 2001 From: Ivan Santiago Paunovic Date: Wed, 10 Jun 2020 16:32:02 -0300 Subject: [PATCH 2/3] Don't mix sample rejected with sample lost status Signed-off-by: Ivan Santiago Paunovic --- rmw_cyclonedds_cpp/src/rmw_node.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/rmw_cyclonedds_cpp/src/rmw_node.cpp b/rmw_cyclonedds_cpp/src/rmw_node.cpp index 06a4ac608..d58ff3459 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -2570,19 +2570,13 @@ extern "C" rmw_ret_t rmw_take_event( case RMW_EVENT_MESSAGE_LOST: { auto ei = static_cast(event_info); auto sub = static_cast(event_handle->data); - dds_sample_lost_status_t st1; - dds_sample_rejected_status_t st2; - if (dds_get_sample_lost_status(sub->enth, &st1) < 0) { + dds_sample_lost_status_t st; + if (dds_get_sample_lost_status(sub->enth, &st) < 0) { *taken = false; return RMW_RET_ERROR; } - if (dds_get_sample_rejected_status(sub->enth, &st2) < 0) { - *taken = false; - return RMW_RET_ERROR; - } - ei->total_count = static_cast(st1.total_count + st2.total_count); - ei->total_count_change = - static_cast(st1.total_count_change + st2.total_count_change); + ei->total_count = static_cast(st.total_count); + ei->total_count_change = static_cast(st.total_count_change); *taken = true; return RMW_RET_OK; } From 13083c6b775612eaea761cd4c9b9644f2a128d5c Mon Sep 17 00:00:00 2001 From: Ivan Santiago Paunovic Date: Wed, 10 Jun 2020 18:33:27 -0300 Subject: [PATCH 3/3] Update rmw_cyclonedds_cpp/src/rmw_node.cpp Signed-off-by: Ivan Santiago Paunovic Co-authored-by: Jacob Perron --- rmw_cyclonedds_cpp/src/rmw_node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmw_cyclonedds_cpp/src/rmw_node.cpp b/rmw_cyclonedds_cpp/src/rmw_node.cpp index d58ff3459..10da48ead 100644 --- a/rmw_cyclonedds_cpp/src/rmw_node.cpp +++ b/rmw_cyclonedds_cpp/src/rmw_node.cpp @@ -2458,7 +2458,7 @@ static const std::unordered_map mask_map{ {RMW_EVENT_OFFERED_DEADLINE_MISSED, DDS_OFFERED_DEADLINE_MISSED_STATUS}, {RMW_EVENT_REQUESTED_QOS_INCOMPATIBLE, DDS_REQUESTED_INCOMPATIBLE_QOS_STATUS}, {RMW_EVENT_OFFERED_QOS_INCOMPATIBLE, DDS_OFFERED_INCOMPATIBLE_QOS_STATUS}, - {RMW_EVENT_MESSAGE_LOST, DDS_SAMPLE_LOST_STATUS | DDS_SAMPLE_REJECTED_STATUS}, + {RMW_EVENT_MESSAGE_LOST, DDS_SAMPLE_LOST_STATUS}, }; static bool is_event_supported(const rmw_event_type_t event_t)