diff --git a/examples/cpp/configuration/CLIParser.hpp b/examples/cpp/configuration/CLIParser.hpp index 7295dcde338..a88d9999a89 100644 --- a/examples/cpp/configuration/CLIParser.hpp +++ b/examples/cpp/configuration/CLIParser.hpp @@ -45,10 +45,10 @@ class CLIParser int32_t max_samples = 5000; int32_t max_instances = 10; int32_t max_samples_per_instance = 400; - uint32_t deadline = fastdds::Duration_t::INFINITE_SECONDS; - uint32_t lifespan = fastdds::Duration_t::INFINITE_SECONDS; - uint32_t liveliness_lease = fastdds::Duration_t::INFINITE_SECONDS; - uint32_t liveliness_assert = fastdds::Duration_t::INFINITE_SECONDS - 1; + uint32_t deadline = 0; + uint32_t lifespan = 0; + uint32_t liveliness_lease = 0; + uint32_t liveliness_assert = 0; std::string partitions = ""; std::string profile_participant = ""; std::string topic_name = "configuration_topic"; @@ -76,7 +76,7 @@ class CLIParser struct publisher_config : public entity_config { uint16_t wait = 0; - uint32_t ack_keep_duration = fastdds::Duration_t::INFINITE_SECONDS; + uint32_t ack_keep_duration = 0; uint32_t interval = 100; uint32_t msg_size = 10; uint32_t ownership_strength = 0; diff --git a/examples/cpp/configuration/PublisherApp.cpp b/examples/cpp/configuration/PublisherApp.cpp index 12aa3bd9053..53886342ce2 100644 --- a/examples/cpp/configuration/PublisherApp.cpp +++ b/examples/cpp/configuration/PublisherApp.cpp @@ -139,16 +139,30 @@ PublisherApp::PublisherApp( "DataWriter initialization failed: ownership strength is only valid with exclusive ownership"); } writer_qos.ownership_strength().value = config.ownership_strength; - writer_qos.deadline().period = eprosima::fastdds::Duration_t(config.deadline * 1e-3); + if (config.deadline > 0) + { + writer_qos.deadline().period = eprosima::fastdds::Duration_t(config.deadline * 1e-3); + } writer_qos.reliable_writer_qos().disable_positive_acks.enabled = config.disable_positive_ack; - writer_qos.reliable_writer_qos().disable_positive_acks.duration = eprosima::fastdds::Duration_t( - config.ack_keep_duration * 1e-3); - writer_qos.lifespan().duration = eprosima::fastdds::Duration_t(config.lifespan * 1e-3); + if (config.ack_keep_duration > 0) + { + writer_qos.reliable_writer_qos().disable_positive_acks.duration = eprosima::fastdds::Duration_t( + config.ack_keep_duration * 1e-3); + } + if (config.lifespan > 0) + { + writer_qos.lifespan().duration = eprosima::fastdds::Duration_t(config.lifespan * 1e-3); + } writer_qos.liveliness().kind = config.liveliness; - writer_qos.liveliness().lease_duration = eprosima::fastdds::Duration_t( - config.liveliness_lease * 1e-3); - writer_qos.liveliness().announcement_period = eprosima::fastdds::Duration_t( - config.liveliness_assert * 1e-3); + if (config.liveliness_lease > 0) + { + writer_qos.liveliness().lease_duration = eprosima::fastdds::Duration_t(config.liveliness_lease * 1e-3); + } + if (config.liveliness_assert > 0) + { + writer_qos.liveliness().announcement_period = eprosima::fastdds::Duration_t( + config.liveliness_assert * 1e-3); + } writer_ = publisher_->create_datawriter(topic_, writer_qos, this, StatusMask::all()); } else diff --git a/examples/cpp/configuration/SubscriberApp.cpp b/examples/cpp/configuration/SubscriberApp.cpp index efadff36b30..9bf1347b4af 100644 --- a/examples/cpp/configuration/SubscriberApp.cpp +++ b/examples/cpp/configuration/SubscriberApp.cpp @@ -125,14 +125,25 @@ SubscriberApp::SubscriberApp( reader_qos.resource_limits().max_instances = config.max_instances; reader_qos.resource_limits().max_samples_per_instance = config.max_samples_per_instance; reader_qos.ownership().kind = config.ownership; - reader_qos.deadline().period = eprosima::fastdds::Duration_t(config.deadline * 1e-3); + if (config.deadline > 0) + { + reader_qos.deadline().period = eprosima::fastdds::Duration_t(config.deadline * 1e-3); + } reader_qos.reliable_reader_qos().disable_positive_acks.enabled = config.disable_positive_ack; - reader_qos.lifespan().duration = eprosima::fastdds::Duration_t(config.lifespan * 1e-3); + if (config.lifespan > 0) + { + reader_qos.lifespan().duration = eprosima::fastdds::Duration_t(config.lifespan * 1e-3); + } reader_qos.liveliness().kind = config.liveliness; - reader_qos.liveliness().lease_duration = eprosima::fastdds::Duration_t( - config.liveliness_lease * 1e-3); - reader_qos.liveliness().announcement_period = eprosima::fastdds::Duration_t( - config.liveliness_assert * 1e-3); + if (config.liveliness_lease > 0) + { + reader_qos.liveliness().lease_duration = eprosima::fastdds::Duration_t(config.liveliness_lease * 1e-3); + } + if (config.liveliness_assert > 0) + { + reader_qos.liveliness().announcement_period = eprosima::fastdds::Duration_t( + config.liveliness_assert * 1e-3); + } reader_ = subscriber_->create_datareader(topic_, reader_qos, this, StatusMask::all()); } else