From 1f8f05dd1cd21f1cdf9c0f96ebb3179772563c8a Mon Sep 17 00:00:00 2001 From: Raul Sanchez-Mateos Date: Fri, 21 Apr 2023 19:22:43 +0200 Subject: [PATCH 1/6] Add all reader callbacks for debugging Signed-off-by: Raul Sanchez-Mateos --- .../reader/rtps/CommonReader.hpp | 49 +++++++++++++ .../src/cpp/reader/rtps/CommonReader.cpp | 73 +++++++++++++++++++ 2 files changed, 122 insertions(+) diff --git a/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp b/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp index ddd8505a0..08d15ebbf 100644 --- a/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp +++ b/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp @@ -112,6 +112,55 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener fastrtps::rtps::RTPSReader*, fastrtps::rtps::MatchingInfo& info) noexcept override; + /** + * @brief Method called when the discovery information of a writer regarding a reader changes. + * + * @param reason The reason motivating this method to be called. + * @param writer_guid The GUID of the writer for which the discovery information changed. + * @param writer_info Discovery information about the writer. Will be @c nullptr for reason @c REMOVED_WRITER. + */ + DDSPIPE_PARTICIPANTS_DllAPI + void on_writer_discovery( + fastrtps::rtps::RTPSReader*, + fastrtps::rtps::WriterDiscoveryInfo::DISCOVERY_STATUS reason, + const fastrtps::rtps::GUID_t& writer_guid, + const fastrtps::rtps::WriterProxyData* writer_info); + + /** + * This method is called when a new Writer is discovered, with a Topic that + * matches that of a local reader, but with an offered QoS that is incompatible + * with the one requested by the local reader + * @param qos A mask with the bits of all incompatible Qos activated. + */ + DDSPIPE_PARTICIPANTS_DllAPI + void on_requested_incompatible_qos( + fastrtps::rtps::RTPSReader*, + eprosima::fastdds::dds::PolicyMask qos); + + /** + * This method is called when the reader detects that one or more samples have been lost. + * + * @param sample_lost_since_last_update The number of samples that were lost since the last time this + * method was called for the same reader. + */ + DDSPIPE_PARTICIPANTS_DllAPI + void on_sample_lost( + fastrtps::rtps::RTPSReader*, + int32_t sample_lost_since_last_update); + + /** + * This method is called when the reader rejects a samples. + * + * @param reason Indicates reason for sample rejection. + * @param change Pointer to the CacheChange_t. This is a const pointer to const data + * to indicate that the user should not dispose of this data himself. + */ + DDSPIPE_PARTICIPANTS_DllAPI + void on_sample_rejected( + fastrtps::rtps::RTPSReader*, + eprosima::fastdds::dds::SampleRejectedStatusKind reason, + const fastrtps::rtps::CacheChange_t* const change); + ///////////////////////// // RPC REQUIRED METHODS ///////////////////////// diff --git a/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp b/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp index b74bb87a4..924d06017 100644 --- a/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp +++ b/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp @@ -454,6 +454,79 @@ void CommonReader::onReaderMatched( } } +void CommonReader::on_writer_discovery( + fastrtps::rtps::RTPSReader*, + fastrtps::rtps::WriterDiscoveryInfo::DISCOVERY_STATUS reason, + const fastrtps::rtps::GUID_t& writer_guid, + const fastrtps::rtps::WriterProxyData* writer_info) +{ + std::string reason_str; + switch (reason) + { + case fastrtps::rtps::WriterDiscoveryInfo::DISCOVERY_STATUS::DISCOVERED_WRITER: + reason_str = "DISCOVERED_WRITER"; + break; + case fastrtps::rtps::WriterDiscoveryInfo::DISCOVERY_STATUS::CHANGED_QOS_WRITER: + reason_str = "CHANGED_QOS_WRITER"; + break; + case fastrtps::rtps::WriterDiscoveryInfo::DISCOVERY_STATUS::REMOVED_WRITER: + reason_str = "REMOVED_WRITER"; + break; + default: + reason_str = "UNKNOWN"; + break; + } + + logInfo(DDSPIPE_RTPS_COMMONREADER_LISTENER, + "Reader " << *this << " discovered a Writer (" << writer_guid << ") in topic " + << writer_info->topicName() << ". Reason: " << reason_str); +} + +void CommonReader::on_requested_incompatible_qos( + fastrtps::rtps::RTPSReader*, + eprosima::fastdds::dds::PolicyMask qos) +{ + logInfo(DDSPIPE_RTPS_COMMONREADER_LISTENER, + "Reader " << *this << " found a remote Topic with incompatible QoS: " << qos); +} + +void CommonReader::on_sample_lost( + fastrtps::rtps::RTPSReader*, + int32_t sample_lost_since_last_update) +{ + logInfo(DDSPIPE_RTPS_COMMONREADER_LISTENER, + "On reader " << *this << " a data sample was lost and will not be received"); +} + +void CommonReader::on_sample_rejected( + fastrtps::rtps::RTPSReader*, + eprosima::fastdds::dds::SampleRejectedStatusKind reason, + const fastrtps::rtps::CacheChange_t* const change) +{ + std::string reason_str; + switch (reason) + { + case eprosima::fastdds::dds::SampleRejectedStatusKind::NOT_REJECTED: + reason_str = "NOT_REJECTED"; + break; + case eprosima::fastdds::dds::SampleRejectedStatusKind::REJECTED_BY_INSTANCES_LIMIT: + reason_str = "REJECTED_BY_INSTANCES_LIMIT"; + break; + case eprosima::fastdds::dds::SampleRejectedStatusKind::REJECTED_BY_SAMPLES_LIMIT: + reason_str = "REJECTED_BY_SAMPLES_LIMIT"; + break; + case eprosima::fastdds::dds::SampleRejectedStatusKind::REJECTED_BY_SAMPLES_PER_INSTANCE_LIMIT: + reason_str = "REJECTED_BY_SAMPLES_PER_INSTANCE_LIMIT"; + break; + default: + reason_str = "UNKNOWN"; + break; + } + logInfo(DDSPIPE_RTPS_COMMONREADER_LISTENER, + "Reader " << *this << " rejected a sample from " << change->writerGUID + << ". Reason: " << reason_str); +} + utils::ReturnCode CommonReader::is_data_correct_( const fastrtps::rtps::CacheChange_t* received_change) const noexcept { From 23eb68c20805611a77672834862ada6339b0bd4d Mon Sep 17 00:00:00 2001 From: Raul Sanchez-Mateos Date: Fri, 21 Apr 2023 19:27:23 +0200 Subject: [PATCH 2/6] Change log level on critial callbacks Signed-off-by: Raul Sanchez-Mateos --- ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp b/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp index 924d06017..8a7364792 100644 --- a/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp +++ b/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp @@ -486,7 +486,7 @@ void CommonReader::on_requested_incompatible_qos( fastrtps::rtps::RTPSReader*, eprosima::fastdds::dds::PolicyMask qos) { - logInfo(DDSPIPE_RTPS_COMMONREADER_LISTENER, + logWarning(DDSPIPE_RTPS_COMMONREADER_LISTENER, "Reader " << *this << " found a remote Topic with incompatible QoS: " << qos); } @@ -494,7 +494,7 @@ void CommonReader::on_sample_lost( fastrtps::rtps::RTPSReader*, int32_t sample_lost_since_last_update) { - logInfo(DDSPIPE_RTPS_COMMONREADER_LISTENER, + logWarning(DDSPIPE_RTPS_COMMONREADER_LISTENER, "On reader " << *this << " a data sample was lost and will not be received"); } From 52781a6db2216687df080d6d259d71eb384e0620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20L=C3=B3pez=20Fern=C3=A1ndez?= Date: Mon, 24 Apr 2023 18:09:31 +0200 Subject: [PATCH 3/6] Fix segfault in CommonReader::on_writer_discovery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juan López Fernández --- ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp b/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp index 8a7364792..b423c2ede 100644 --- a/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp +++ b/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp @@ -477,9 +477,10 @@ void CommonReader::on_writer_discovery( break; } + std::string topic_name = writer_info != nullptr ? writer_info->topicName().to_string() : "UNKNOWN"; logInfo(DDSPIPE_RTPS_COMMONREADER_LISTENER, "Reader " << *this << " discovered a Writer (" << writer_guid << ") in topic " - << writer_info->topicName() << ". Reason: " << reason_str); + << topic_name << ". Reason: " << reason_str); } void CommonReader::on_requested_incompatible_qos( From 263e9595dabd1e7b4789b7f3431fbfca2ee222a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20L=C3=B3pez=20Fern=C3=A1ndez?= Date: Mon, 29 May 2023 14:33:57 +0200 Subject: [PATCH 4/6] Delete reader's on_writer_discovery callback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juan López Fernández --- .../reader/rtps/CommonReader.hpp | 14 --------- .../src/cpp/reader/rtps/CommonReader.cpp | 29 ------------------- 2 files changed, 43 deletions(-) diff --git a/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp b/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp index 08d15ebbf..24320c31f 100644 --- a/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp +++ b/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp @@ -112,20 +112,6 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener fastrtps::rtps::RTPSReader*, fastrtps::rtps::MatchingInfo& info) noexcept override; - /** - * @brief Method called when the discovery information of a writer regarding a reader changes. - * - * @param reason The reason motivating this method to be called. - * @param writer_guid The GUID of the writer for which the discovery information changed. - * @param writer_info Discovery information about the writer. Will be @c nullptr for reason @c REMOVED_WRITER. - */ - DDSPIPE_PARTICIPANTS_DllAPI - void on_writer_discovery( - fastrtps::rtps::RTPSReader*, - fastrtps::rtps::WriterDiscoveryInfo::DISCOVERY_STATUS reason, - const fastrtps::rtps::GUID_t& writer_guid, - const fastrtps::rtps::WriterProxyData* writer_info); - /** * This method is called when a new Writer is discovered, with a Topic that * matches that of a local reader, but with an offered QoS that is incompatible diff --git a/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp b/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp index b423c2ede..95e534070 100644 --- a/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp +++ b/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp @@ -454,35 +454,6 @@ void CommonReader::onReaderMatched( } } -void CommonReader::on_writer_discovery( - fastrtps::rtps::RTPSReader*, - fastrtps::rtps::WriterDiscoveryInfo::DISCOVERY_STATUS reason, - const fastrtps::rtps::GUID_t& writer_guid, - const fastrtps::rtps::WriterProxyData* writer_info) -{ - std::string reason_str; - switch (reason) - { - case fastrtps::rtps::WriterDiscoveryInfo::DISCOVERY_STATUS::DISCOVERED_WRITER: - reason_str = "DISCOVERED_WRITER"; - break; - case fastrtps::rtps::WriterDiscoveryInfo::DISCOVERY_STATUS::CHANGED_QOS_WRITER: - reason_str = "CHANGED_QOS_WRITER"; - break; - case fastrtps::rtps::WriterDiscoveryInfo::DISCOVERY_STATUS::REMOVED_WRITER: - reason_str = "REMOVED_WRITER"; - break; - default: - reason_str = "UNKNOWN"; - break; - } - - std::string topic_name = writer_info != nullptr ? writer_info->topicName().to_string() : "UNKNOWN"; - logInfo(DDSPIPE_RTPS_COMMONREADER_LISTENER, - "Reader " << *this << " discovered a Writer (" << writer_guid << ") in topic " - << topic_name << ". Reason: " << reason_str); -} - void CommonReader::on_requested_incompatible_qos( fastrtps::rtps::RTPSReader*, eprosima::fastdds::dds::PolicyMask qos) From 33769eb6ca604fdf70a7d7ebea4038add760960d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20L=C3=B3pez=20Fern=C3=A1ndez?= Date: Mon, 29 May 2023 14:40:36 +0200 Subject: [PATCH 5/6] Add writer's on_requested_incompatible_qos callback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juan López Fernández --- .../ddspipe_participants/reader/rtps/CommonReader.hpp | 6 +++--- .../ddspipe_participants/writer/rtps/CommonWriter.hpp | 11 +++++++++++ .../src/cpp/reader/rtps/CommonReader.cpp | 8 ++++---- .../src/cpp/writer/rtps/CommonWriter.cpp | 8 ++++++++ 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp b/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp index 24320c31f..a0ca6c627 100644 --- a/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp +++ b/ddspipe_participants/include/ddspipe_participants/reader/rtps/CommonReader.hpp @@ -121,7 +121,7 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener DDSPIPE_PARTICIPANTS_DllAPI void on_requested_incompatible_qos( fastrtps::rtps::RTPSReader*, - eprosima::fastdds::dds::PolicyMask qos); + eprosima::fastdds::dds::PolicyMask qos) noexcept override; /** * This method is called when the reader detects that one or more samples have been lost. @@ -132,7 +132,7 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener DDSPIPE_PARTICIPANTS_DllAPI void on_sample_lost( fastrtps::rtps::RTPSReader*, - int32_t sample_lost_since_last_update); + int32_t sample_lost_since_last_update) noexcept override; /** * This method is called when the reader rejects a samples. @@ -145,7 +145,7 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener void on_sample_rejected( fastrtps::rtps::RTPSReader*, eprosima::fastdds::dds::SampleRejectedStatusKind reason, - const fastrtps::rtps::CacheChange_t* const change); + const fastrtps::rtps::CacheChange_t* const change) noexcept override; ///////////////////////// // RPC REQUIRED METHODS diff --git a/ddspipe_participants/include/ddspipe_participants/writer/rtps/CommonWriter.hpp b/ddspipe_participants/include/ddspipe_participants/writer/rtps/CommonWriter.hpp index 6009eef8e..2a36fc7fa 100644 --- a/ddspipe_participants/include/ddspipe_participants/writer/rtps/CommonWriter.hpp +++ b/ddspipe_participants/include/ddspipe_participants/writer/rtps/CommonWriter.hpp @@ -108,6 +108,17 @@ class CommonWriter : public BaseWriter, public fastrtps::rtps::WriterListener fastrtps::rtps::RTPSWriter*, fastrtps::rtps::MatchingInfo& info) noexcept override; + /** + * This method is called when a new Reader is discovered, with a Topic that + * matches that of a local writer, but with a requested QoS that is incompatible + * with the one offered by the local writer + * @param qos A mask with the bits of all incompatible Qos activated. + */ + DDSPIPE_PARTICIPANTS_DllAPI + void on_offered_incompatible_qos( + fastrtps::rtps::RTPSWriter*, + eprosima::fastdds::dds::PolicyMask qos) noexcept override; + ///////////////////// // STATIC ATTRIBUTES ///////////////////// diff --git a/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp b/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp index 95e534070..c0292d1bc 100644 --- a/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp +++ b/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp @@ -456,15 +456,15 @@ void CommonReader::onReaderMatched( void CommonReader::on_requested_incompatible_qos( fastrtps::rtps::RTPSReader*, - eprosima::fastdds::dds::PolicyMask qos) + eprosima::fastdds::dds::PolicyMask qos) noexcept { logWarning(DDSPIPE_RTPS_COMMONREADER_LISTENER, - "Reader " << *this << " found a remote Topic with incompatible QoS: " << qos); + "Reader " << *this << " found a remote Writer with incompatible QoS: " << qos); } void CommonReader::on_sample_lost( fastrtps::rtps::RTPSReader*, - int32_t sample_lost_since_last_update) + int32_t sample_lost_since_last_update) noexcept { logWarning(DDSPIPE_RTPS_COMMONREADER_LISTENER, "On reader " << *this << " a data sample was lost and will not be received"); @@ -473,7 +473,7 @@ void CommonReader::on_sample_lost( void CommonReader::on_sample_rejected( fastrtps::rtps::RTPSReader*, eprosima::fastdds::dds::SampleRejectedStatusKind reason, - const fastrtps::rtps::CacheChange_t* const change) + const fastrtps::rtps::CacheChange_t* const change) noexcept { std::string reason_str; switch (reason) diff --git a/ddspipe_participants/src/cpp/writer/rtps/CommonWriter.cpp b/ddspipe_participants/src/cpp/writer/rtps/CommonWriter.cpp index ba4eac76c..f333c25a7 100644 --- a/ddspipe_participants/src/cpp/writer/rtps/CommonWriter.cpp +++ b/ddspipe_participants/src/cpp/writer/rtps/CommonWriter.cpp @@ -123,6 +123,14 @@ void CommonWriter::onWriterMatched( } } +void CommonWriter::on_offered_incompatible_qos( + fastrtps::rtps::RTPSWriter*, + eprosima::fastdds::dds::PolicyMask qos) noexcept +{ + logWarning(DDSPIPE_RTPS_COMMONWRITER_LISTENER, + "Writer " << *this << " found a remote Reader with incompatible QoS: " << qos); +} + bool CommonWriter::come_from_this_participant_( const fastrtps::rtps::GUID_t guid) const noexcept { From 7da5a015e3ec879de7832b396bab6fa05ee77d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20L=C3=B3pez=20Fern=C3=A1ndez?= Date: Mon, 29 May 2023 14:49:18 +0200 Subject: [PATCH 6/6] Uncrustify MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juan López Fernández --- ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp b/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp index c0292d1bc..46af5849a 100644 --- a/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp +++ b/ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp @@ -496,7 +496,7 @@ void CommonReader::on_sample_rejected( } logInfo(DDSPIPE_RTPS_COMMONREADER_LISTENER, "Reader " << *this << " rejected a sample from " << change->writerGUID - << ". Reason: " << reason_str); + << ". Reason: " << reason_str); } utils::ReturnCode CommonReader::is_data_correct_(