Skip to content

Commit

Permalink
Add more debugging listener callbacks (#44)
Browse files Browse the repository at this point in the history
* Add all reader callbacks for debugging

Signed-off-by: Raul Sanchez-Mateos <[email protected]>

* Change log level on critial callbacks

Signed-off-by: Raul Sanchez-Mateos <[email protected]>

* Fix segfault in CommonReader::on_writer_discovery

Signed-off-by: Juan López Fernández <[email protected]>

* Delete reader's on_writer_discovery callback

Signed-off-by: Juan López Fernández <[email protected]>

* Add writer's on_requested_incompatible_qos callback

Signed-off-by: Juan López Fernández <[email protected]>

* Uncrustify

Signed-off-by: Juan López Fernández <[email protected]>

---------

Signed-off-by: Raul Sanchez-Mateos <[email protected]>
Signed-off-by: Juan López Fernández <[email protected]>
Co-authored-by: Raul Sanchez-Mateos <[email protected]>
  • Loading branch information
juanlofer-eprosima and rsanchez15 authored Jun 14, 2023
1 parent bf7928b commit 1113dee
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,41 @@ class CommonReader : public BaseReader, public fastrtps::rtps::ReaderListener
fastrtps::rtps::RTPSReader*,
fastrtps::rtps::MatchingInfo& info) noexcept override;

/**
* 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) noexcept override;

/**
* 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) noexcept override;

/**
* 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) noexcept override;

/////////////////////////
// RPC REQUIRED METHODS
/////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
/////////////////////
Expand Down
45 changes: 45 additions & 0 deletions ddspipe_participants/src/cpp/reader/rtps/CommonReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,51 @@ void CommonReader::onReaderMatched(
}
}

void CommonReader::on_requested_incompatible_qos(
fastrtps::rtps::RTPSReader*,
eprosima::fastdds::dds::PolicyMask qos) noexcept
{
logWarning(DDSPIPE_RTPS_COMMONREADER_LISTENER,
"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) noexcept
{
logWarning(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) noexcept
{
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
{
Expand Down
8 changes: 8 additions & 0 deletions ddspipe_participants/src/cpp/writer/rtps/CommonWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 1113dee

Please sign in to comment.