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

update dds-sniffer with --topics, topic-info #13661

Merged
merged 3 commits into from
Jan 8, 2025
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
18 changes: 12 additions & 6 deletions third-party/realdds/include/realdds/dds-participant.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ class DomainParticipant;
class DomainParticipantFactory;
} // namespace dds
} // namespace fastdds
namespace fastrtps {
namespace rtps {
class WriterProxyData;
class ReaderProxyData;
} // namespace rtps
} // namespace fastrtps
} // namespace eprosima
#ifdef BUILD_EASYLOGGINGPP
namespace el {
Expand Down Expand Up @@ -153,9 +159,9 @@ class dds_participant
{
friend class dds_participant;

std::function< void( dds_guid, char const* topic_name ) > _on_writer_added;
std::function< void( eprosima::fastrtps::rtps::WriterProxyData const & ) > _on_writer_added;
std::function< void( dds_guid, char const* topic_name ) > _on_writer_removed;
std::function< void( dds_guid, char const* topic_name ) > _on_reader_added;
std::function< void( eprosima::fastrtps::rtps::ReaderProxyData const & ) > _on_reader_added;
std::function< void( dds_guid, char const* topic_name ) > _on_reader_removed;
std::function< void( dds_guid, char const* participant_name ) > _on_participant_added;
std::function< void( dds_guid, char const* participant_name ) > _on_participant_removed;
Expand All @@ -164,7 +170,7 @@ class dds_participant
listener() = default;

public:
listener* on_writer_added( std::function< void( dds_guid guid, char const* topic_name ) > callback )
listener* on_writer_added( std::function< void( eprosima::fastrtps::rtps::WriterProxyData const & ) > callback )
{
_on_writer_added = std::move( callback );
return this;
Expand All @@ -174,7 +180,7 @@ class dds_participant
_on_writer_removed = std::move( callback );
return this;
}
listener* on_reader_added( std::function< void( dds_guid guid, char const* topic_name ) > callback )
listener* on_reader_added( std::function< void( eprosima::fastrtps::rtps::ReaderProxyData const & ) > callback )
{
_on_reader_added = std::move( callback );
return this;
Expand Down Expand Up @@ -228,9 +234,9 @@ class dds_participant
std::shared_ptr< listener_impl > _domain_listener;
std::atomic< uint32_t > _next_entity_id{ 0 }; // for create_guid()

void on_writer_added( dds_guid, char const * topic_name );
void on_writer_added( eprosima::fastrtps::rtps::WriterProxyData const & );
void on_writer_removed( dds_guid, char const * topic_name );
void on_reader_added( dds_guid, char const * topic_name );
void on_reader_added( eprosima::fastrtps::rtps::ReaderProxyData const & );
void on_reader_removed( dds_guid, char const * topic_name );
void on_participant_added( dds_guid, char const * participant_name );
void on_participant_removed( dds_guid, char const * participant_name );
Expand Down
17 changes: 17 additions & 0 deletions third-party/realdds/include/realdds/dds-serialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@ namespace realdds {
class dds_participant;


struct print_writer_info
{
eprosima::fastrtps::rtps::WriterProxyData const & info;
print_writer_info( eprosima::fastrtps::rtps::WriterProxyData const & info ) : info( info ) {}
};
std::ostream & operator<<( std::ostream & os, print_writer_info const & );


struct print_reader_info
{
eprosima::fastrtps::rtps::ReaderProxyData const & info;
print_reader_info( eprosima::fastrtps::rtps::ReaderProxyData const & info ) : info( info ) {}
};
std::ostream & operator<<( std::ostream & os, print_reader_info const & );



eprosima::fastdds::dds::ReliabilityQosPolicyKind reliability_kind_from_string( std::string const & );
eprosima::fastdds::dds::DurabilityQosPolicyKind durability_kind_from_string( std::string const & );
eprosima::fastdds::dds::HistoryQosPolicyKind history_kind_from_string( std::string const & );
Expand Down
10 changes: 6 additions & 4 deletions third-party/realdds/py/pyrealdds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
#include <fastdds/dds/domain/qos/DomainParticipantQos.hpp>
#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastrtps/types/DynamicType.h>
#include <fastdds/rtps/builtin/data/WriterProxyData.h>
#include <fastdds/rtps/builtin/data/ReaderProxyData.h>

#include <rsutils/py/pybind11.h>

Expand Down Expand Up @@ -248,8 +250,8 @@ PYBIND11_MODULE(NAME, m) {
.def( FN_FWD( dds_participant::listener,
on_writer_added,
( dds_guid guid, char const * topic_name ),
( dds_guid guid, char const * topic_name ),
callback( guid, topic_name ); ) )
( eprosima::fastrtps::rtps::WriterProxyData const & data ),
callback( data.guid(), data.topicName().c_str() ); ) )
.def( FN_FWD( dds_participant::listener,
on_writer_removed,
( dds_guid guid, char const * topic_name ),
Expand All @@ -258,8 +260,8 @@ PYBIND11_MODULE(NAME, m) {
.def( FN_FWD( dds_participant::listener,
on_reader_added,
( dds_guid guid, char const * topic_name ),
( dds_guid guid, char const * topic_name ),
callback( guid, topic_name ); ) )
( eprosima::fastrtps::rtps::ReaderProxyData const & data ),
callback( data.guid(), data.topicName().c_str() ); ) )
.def( FN_FWD( dds_participant::listener,
on_reader_removed,
( dds_guid guid, char const * topic_name ),
Expand Down
12 changes: 6 additions & 6 deletions third-party/realdds/src/dds-participant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ struct dds_participant::listener_impl : public eprosima::fastdds::dds::DomainPar
/* Process the case when a new publisher was found in the domain */
LOG_DEBUG( _owner.name() << ": +writer (" << _owner.print( info.info.guid() ) << ") publishing "
<< info.info );
_owner.on_writer_added( info.info.guid(), info.info.topicName().c_str() );
_owner.on_writer_added( info.info );
break;

case eprosima::fastrtps::rtps::WriterDiscoveryInfo::REMOVED_WRITER:
Expand All @@ -163,7 +163,7 @@ struct dds_participant::listener_impl : public eprosima::fastdds::dds::DomainPar
{
case eprosima::fastrtps::rtps::ReaderDiscoveryInfo::DISCOVERED_READER:
LOG_DEBUG( _owner.name() << ": +reader (" << _owner.print( info.info.guid() ) << ") of " << info.info );
_owner.on_reader_added( info.info.guid(), info.info.topicName().c_str() );
_owner.on_reader_added( info.info );
break;

case eprosima::fastrtps::rtps::ReaderDiscoveryInfo::REMOVED_READER:
Expand Down Expand Up @@ -359,14 +359,14 @@ std::string dds_participant::print( dds_guid const & guid_to_print ) const
}


void dds_participant::on_writer_added( dds_guid guid, char const * topic_name )
void dds_participant::on_writer_added( eprosima::fastrtps::rtps::WriterProxyData const & data )
{
for( auto & wl : _listeners )
{
if( auto l = wl.lock() )
{
if( l->_on_writer_added )
l->_on_writer_added( guid, topic_name );
l->_on_writer_added( data );
}
}
}
Expand All @@ -385,14 +385,14 @@ void dds_participant::on_writer_removed( dds_guid guid, char const * topic_name
}


void dds_participant::on_reader_added( dds_guid guid, char const * topic_name )
void dds_participant::on_reader_added( eprosima::fastrtps::rtps::ReaderProxyData const & data )
{
for( auto & wl : _listeners )
{
if( auto l = wl.lock() )
{
if( l->_on_reader_added )
l->_on_reader_added( guid, topic_name );
l->_on_reader_added( data );
}
}
}
Expand Down
48 changes: 30 additions & 18 deletions third-party/realdds/src/dds-serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,30 +416,14 @@ std::ostream & operator<<( std::ostream & os, RemoteLocatorsAllocationAttributes

std::ostream & operator<<( std::ostream & os, WriterProxyData const & info )
{
field::group group;
os << "'" << info.topicName() << "' " << group;
os << /*field::separator << "type" <<*/ field::value << info.typeName();
os << /*field::separator << "reliability" << field::group() <<*/ info.m_qos.m_reliability;
if( ! ( info.m_qos.m_durability == eprosima::fastdds::dds::DurabilityQosPolicy() ) )
os << /*field::separator << "durability" << field::group() <<*/ info.m_qos.m_durability;
if( ! ( info.m_qos.m_liveliness == eprosima::fastdds::dds::LivelinessQosPolicy() ) )
os << field::separator << "liveliness" << field::value << info.m_qos.m_liveliness;
if( info.m_qos.m_publishMode.flow_controller_name
&& info.m_qos.m_publishMode.flow_controller_name != eprosima::fastdds::rtps::FASTDDS_FLOW_CONTROLLER_DEFAULT )
os << field::separator << "flow-controller" << field::value << "'"
<< info.m_qos.m_publishMode.flow_controller_name << "'";
os << "'" << info.topicName() << "' " << field::group() << realdds::print_writer_info( info );
return os;
}


std::ostream & operator<<( std::ostream & os, ReaderProxyData const & info )
{
field::group group;
os << "'" << info.topicName() << "' " << group;
os << /*field::separator << "type" <<*/ field::value << info.typeName();
os << /*field::separator << "reliability" << field::group() <<*/ info.m_qos.m_reliability;
if( ! ( info.m_qos.m_durability == eprosima::fastdds::dds::DurabilityQosPolicy() ) )
os << /*field::separator << "durability" << field::group() <<*/ info.m_qos.m_durability;
os << "'" << info.topicName() << "' " << field::group() << realdds::print_reader_info( info );
return os;
}

Expand Down Expand Up @@ -493,6 +477,34 @@ std::ostream & operator<<( std::ostream & os, BuiltinAttributes const & qos )
namespace realdds {


std::ostream & operator<<( std::ostream & os, print_writer_info const & pwi )
{
auto & info = pwi.info;
os << /*field::separator << "type" <<*/ field::value << info.typeName();
os << /*field::separator << "reliability" << field::group() <<*/ info.m_qos.m_reliability;
if( ! ( info.m_qos.m_durability == eprosima::fastdds::dds::DurabilityQosPolicy() ) )
os << /*field::separator << "durability" << field::group() <<*/ info.m_qos.m_durability;
if( ! ( info.m_qos.m_liveliness == eprosima::fastdds::dds::LivelinessQosPolicy() ) )
os << field::separator << "liveliness" << field::value << info.m_qos.m_liveliness;
if( info.m_qos.m_publishMode.flow_controller_name
&& info.m_qos.m_publishMode.flow_controller_name != eprosima::fastdds::rtps::FASTDDS_FLOW_CONTROLLER_DEFAULT )
os << field::separator << "flow-controller" << field::value << "'"
<< info.m_qos.m_publishMode.flow_controller_name << "'";
return os;
}


std::ostream & operator<<( std::ostream & os, print_reader_info const & pri )
{
auto & info = pri.info;
os << /*field::separator << "type" <<*/ field::value << info.typeName();
os << /*field::separator << "reliability" << field::group() <<*/ info.m_qos.m_reliability;
if( ! ( info.m_qos.m_durability == eprosima::fastdds::dds::DurabilityQosPolicy() ) )
os << /*field::separator << "durability" << field::group() <<*/ info.m_qos.m_durability;
return os;
}


eprosima::fastdds::dds::ReliabilityQosPolicyKind reliability_kind_from_string( std::string const & s )
{
if( s == "best-effort" )
Expand Down
Loading
Loading