Skip to content

Commit 252ff37

Browse files
Fix non-defined duration Qos in configuration example (#5001)
* Refs #19563: Fix Durability QoS setup in configuration example Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com> * Refs #19563: Update Readme with default values Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com> --------- Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
1 parent 9b09ada commit 252ff37

4 files changed

Lines changed: 51 additions & 19 deletions

File tree

examples/cpp/configuration/CLIParser.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ class CLIParser
4545
int32_t max_samples = 5000;
4646
int32_t max_instances = 10;
4747
int32_t max_samples_per_instance = 400;
48-
uint32_t deadline = fastdds::Duration_t::INFINITE_SECONDS;
49-
uint32_t lifespan = fastdds::Duration_t::INFINITE_SECONDS;
50-
uint32_t liveliness_lease = fastdds::Duration_t::INFINITE_SECONDS;
51-
uint32_t liveliness_assert = fastdds::Duration_t::INFINITE_SECONDS - 1;
48+
uint32_t deadline = 0;
49+
uint32_t lifespan = 0;
50+
uint32_t liveliness_lease = 0;
51+
uint32_t liveliness_assert = 0;
5252
std::string partitions = "";
5353
std::string profile_participant = "";
5454
std::string topic_name = "configuration_topic";
@@ -76,7 +76,7 @@ class CLIParser
7676
struct publisher_config : public entity_config
7777
{
7878
uint16_t wait = 0;
79-
uint32_t ack_keep_duration = fastdds::Duration_t::INFINITE_SECONDS;
79+
uint32_t ack_keep_duration = 0;
8080
uint32_t interval = 100;
8181
uint32_t msg_size = 10;
8282
uint32_t ownership_strength = 0;

examples/cpp/configuration/PublisherApp.cpp

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,30 @@ PublisherApp::PublisherApp(
139139
"DataWriter initialization failed: ownership strength is only valid with exclusive ownership");
140140
}
141141
writer_qos.ownership_strength().value = config.ownership_strength;
142-
writer_qos.deadline().period = eprosima::fastdds::Duration_t(config.deadline * 1e-3);
142+
if (config.deadline > 0)
143+
{
144+
writer_qos.deadline().period = eprosima::fastdds::Duration_t(config.deadline * 1e-3);
145+
}
143146
writer_qos.reliable_writer_qos().disable_positive_acks.enabled = config.disable_positive_ack;
144-
writer_qos.reliable_writer_qos().disable_positive_acks.duration = eprosima::fastdds::Duration_t(
145-
config.ack_keep_duration * 1e-3);
146-
writer_qos.lifespan().duration = eprosima::fastdds::Duration_t(config.lifespan * 1e-3);
147+
if (config.ack_keep_duration > 0)
148+
{
149+
writer_qos.reliable_writer_qos().disable_positive_acks.duration = eprosima::fastdds::Duration_t(
150+
config.ack_keep_duration * 1e-3);
151+
}
152+
if (config.lifespan > 0)
153+
{
154+
writer_qos.lifespan().duration = eprosima::fastdds::Duration_t(config.lifespan * 1e-3);
155+
}
147156
writer_qos.liveliness().kind = config.liveliness;
148-
writer_qos.liveliness().lease_duration = eprosima::fastdds::Duration_t(
149-
config.liveliness_lease * 1e-3);
150-
writer_qos.liveliness().announcement_period = eprosima::fastdds::Duration_t(
151-
config.liveliness_assert * 1e-3);
157+
if (config.liveliness_lease > 0)
158+
{
159+
writer_qos.liveliness().lease_duration = eprosima::fastdds::Duration_t(config.liveliness_lease * 1e-3);
160+
}
161+
if (config.liveliness_assert > 0)
162+
{
163+
writer_qos.liveliness().announcement_period = eprosima::fastdds::Duration_t(
164+
config.liveliness_assert * 1e-3);
165+
}
152166
writer_ = publisher_->create_datawriter(topic_, writer_qos, this, StatusMask::all());
153167
}
154168
else

examples/cpp/configuration/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ Otherwise, the entities are considered incompatible (and they will not match).
138138
The argument **``-i``** ``<period>`` or **``--interval``** ``<period>`` configures the **publisher** application with the sending samples period (in milliseconds).
139139
It should be always **greater** than the deadline period, otherwise ``on_offered_deadline_missed`` will be triggered any time a sample is sent.
140140

141+
If **``--deadline``** is not configured, it takes the _eProsima Fast DDS_ default value (infinite).
142+
141143
## Disable positive ACKs QoS
142144

143145
Using argument **``--disable-positive-ack``** will configure the corresponding endpoint to **not** exchange positive acknowledge messages.
@@ -172,6 +174,8 @@ The following table represents the compatibility matrix (compatible ✔️ vs in
172174

173175
The argument **``--ack-keep-duration``** ``<duration>`` configures the **publisher** application with the duration (in milliseconds) it keeps the data before considering it as acknowledged.
174176

177+
If **``--ack-keep-duration``** is not configured, it takes the _eProsima Fast DDS_ default value (infinite).
178+
175179
## Durability QoS
176180

177181
Using argument **``--transient-local``** will configure the corresponding endpoint with **``TRANSIENT_LOCAL``** durability QoS.
@@ -282,6 +286,9 @@ The following table represents the compatibility matrix (compatible ✔️ vs in
282286
The argument **``-i``** ``<period>`` or **``--interval``** ``<period>`` configures the **publisher** application with the sending samples period (in milliseconds).
283287
It should be always **lower** than the liveliness lease duration, otherwise liveliness will be lost after sending each sample and recovered when sending the next sample.
284288

289+
290+
If **``--liveliness``** or **``--liveliness-assert``** are not configured, they take the _eProsima Fast DDS_ default values (infinite).
291+
285292
## Ownership QoS
286293

287294
Using argument **``-o``** or **``--ownership``** will configure the corresponding endpoint with **``EXCLUSIVE``** [ownership QoS kind](https://fast-dds.docs.eprosima.com/en/latest/fastdds/dds_layer/core/policy/standardQosPolicies.html#ownershipqospolicykind).

examples/cpp/configuration/SubscriberApp.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,25 @@ SubscriberApp::SubscriberApp(
125125
reader_qos.resource_limits().max_instances = config.max_instances;
126126
reader_qos.resource_limits().max_samples_per_instance = config.max_samples_per_instance;
127127
reader_qos.ownership().kind = config.ownership;
128-
reader_qos.deadline().period = eprosima::fastdds::Duration_t(config.deadline * 1e-3);
128+
if (config.deadline > 0)
129+
{
130+
reader_qos.deadline().period = eprosima::fastdds::Duration_t(config.deadline * 1e-3);
131+
}
129132
reader_qos.reliable_reader_qos().disable_positive_acks.enabled = config.disable_positive_ack;
130-
reader_qos.lifespan().duration = eprosima::fastdds::Duration_t(config.lifespan * 1e-3);
133+
if (config.lifespan > 0)
134+
{
135+
reader_qos.lifespan().duration = eprosima::fastdds::Duration_t(config.lifespan * 1e-3);
136+
}
131137
reader_qos.liveliness().kind = config.liveliness;
132-
reader_qos.liveliness().lease_duration = eprosima::fastdds::Duration_t(
133-
config.liveliness_lease * 1e-3);
134-
reader_qos.liveliness().announcement_period = eprosima::fastdds::Duration_t(
135-
config.liveliness_assert * 1e-3);
138+
if (config.liveliness_lease > 0)
139+
{
140+
reader_qos.liveliness().lease_duration = eprosima::fastdds::Duration_t(config.liveliness_lease * 1e-3);
141+
}
142+
if (config.liveliness_assert > 0)
143+
{
144+
reader_qos.liveliness().announcement_period = eprosima::fastdds::Duration_t(
145+
config.liveliness_assert * 1e-3);
146+
}
136147
reader_ = subscriber_->create_datareader(topic_, reader_qos, this, StatusMask::all());
137148
}
138149
else

0 commit comments

Comments
 (0)