Издатель и подписчик FastDDS не совпадают в демонстрационном кодеC++

Программы на C++. Форум разработчиков
Ответить Пред. темаСлед. тема
Гость
 Издатель и подписчик FastDDS не совпадают в демонстрационном коде

Сообщение Гость »


I am trying to set up the Hello World example from the FastDDS tutorial here: https://fast-dds.docs.eprosima.com/en/l ... e_app.html

When I run the publisher and subscriber (separate terminals), they can't find each other. I never get the "Publisher matched" and "Subscriber matched" lines.

What can I look for here? Is there a way to see all the topics that are being published/subscribed to? Is there some configuration to be done to run them on localhost?

All that I can think to do is double check the topic names and add a cout line to print if the publisher wasn't matched. I haven't changed the code from the tutorial page other than adding a print statement so I'm not sure how to proceed.

Here in the Publisher code:

/** * @file HelloWorldPublisher.cpp * */ #include "HelloWorldPubSubTypes.h" #include #include #include #include #include #include #include #include using namespace eprosima::fastdds::dds; class HelloWorldPublisher { private: HelloWorld hello_; DomainParticipant* participant_; Publisher* publisher_; Topic* topic_; DataWriter* writer_; TypeSupport type_; class PubListener : public DataWriterListener { public: PubListener() : matched_(0) { } ~PubListener() override { } void on_publication_matched( DataWriter*, const PublicationMatchedStatus& info) override { if (info.current_count_change == 1) { matched_ = info.total_count; std::cout create_publisher(PUBLISHER_QOS_DEFAULT, nullptr); if (publisher_ == nullptr) { return false; } // Create the DataWriter writer_ = publisher_->create_datawriter(topic_, DATAWRITER_QOS_DEFAULT, &listener_); if (writer_ == nullptr) { return false; } return true; } //!Send a publication bool publish() { if (listener_.matched_ > 0) { hello_.index(hello_.index() + 1); writer_->write(&hello_); return true; } return false; } //!Run the Publisher void run( uint32_t samples) { uint32_t samples_sent = 0; while (samples_sent < samples) { if (publish()) { samples_sent++; std::cout

Источник: https://stackoverflow.com/questions/780 ... -demo-code
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C++»