Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more debugging listener callbacks #44

Merged
merged 6 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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