Skip to content

Commit

Permalink
Changed QoS assignments in throughput and latency examples
Browse files Browse the repository at this point in the history
Signed-off-by: Martijn Reicher <[email protected]>
  • Loading branch information
reicheratwork authored and eboasson committed Feb 2, 2023
1 parent 1a56e4b commit 8b82dc5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 34 deletions.
23 changes: 11 additions & 12 deletions examples/roundtrip/ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,14 +448,17 @@ static dds_entity_t prepare_dds(dds_entity_t *wr, dds_entity_t *rd, dds_entity_t
const char *pubPartitions[] = { "ping" };
const char *subPartitions[] = { "pong" };
dds_qos_t *pubQos;
dds_qos_t *dwQos;
dds_qos_t *drQos;
dds_qos_t *subQos;
dds_qos_t *tQos;
dds_qos_t *wQos;

/* A DDS_Topic is created for our sample type on the domain participant. */
topic = dds_create_topic (participant, &RoundTripModule_DataType_desc, "RoundTrip", NULL, NULL);
tQos = dds_create_qos ();
dds_qset_reliability (tQos, DDS_RELIABILITY_RELIABLE, DDS_SECS (10));
topic = dds_create_topic (participant, &RoundTripModule_DataType_desc, "RoundTrip", tQos, NULL);
if (topic < 0)
DDS_FATAL("dds_create_topic: %s\n", dds_strretcode(-topic));
dds_delete_qos (tQos);

/* A DDS_Publisher is created on the domain participant. */
pubQos = dds_create_qos ();
Expand All @@ -467,13 +470,12 @@ static dds_entity_t prepare_dds(dds_entity_t *wr, dds_entity_t *rd, dds_entity_t
dds_delete_qos (pubQos);

/* A DDS_DataWriter is created on the Publisher & Topic with a modified Qos. */
dwQos = dds_create_qos ();
dds_qset_reliability (dwQos, DDS_RELIABILITY_RELIABLE, DDS_SECS (10));
dds_qset_writer_data_lifecycle (dwQos, false);
*wr = dds_create_writer (publisher, topic, dwQos, NULL);
wQos = dds_create_qos ();
dds_qset_writer_data_lifecycle (wQos, false);
*wr = dds_create_writer (publisher, topic, wQos, NULL);
if (*wr < 0)
DDS_FATAL("dds_create_writer: %s\n", dds_strretcode(-*wr));
dds_delete_qos (dwQos);
dds_delete_qos (wQos);

/* A DDS_Subscriber is created on the domain participant. */
subQos = dds_create_qos ();
Expand All @@ -485,12 +487,9 @@ static dds_entity_t prepare_dds(dds_entity_t *wr, dds_entity_t *rd, dds_entity_t
DDS_FATAL("dds_create_subscriber: %s\n", dds_strretcode(-subscriber));
dds_delete_qos (subQos);
/* A DDS_DataReader is created on the Subscriber & Topic with a modified QoS. */
drQos = dds_create_qos ();
dds_qset_reliability (drQos, DDS_RELIABILITY_RELIABLE, DDS_SECS(10));
*rd = dds_create_reader (subscriber, topic, drQos, listener);
*rd = dds_create_reader (subscriber, topic, NULL, listener);
if (*rd < 0)
DDS_FATAL("dds_create_reader: %s\n", dds_strretcode(-*rd));
dds_delete_qos (drQos);

waitSet = dds_create_waitset (participant);
if (listener == NULL) {
Expand Down
11 changes: 5 additions & 6 deletions examples/roundtrip/pong.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,12 @@ static dds_entity_t prepare_dds(dds_entity_t *wr, dds_entity_t *rd, dds_entity_t

/* A DDS Topic is created for our sample type on the domain participant. */

topic = dds_create_topic (participant, &RoundTripModule_DataType_desc, "RoundTrip", NULL, NULL);
qos = dds_create_qos ();
dds_qset_reliability (qos, DDS_RELIABILITY_RELIABLE, DDS_SECS(10));
topic = dds_create_topic (participant, &RoundTripModule_DataType_desc, "RoundTrip", qos, NULL);
if (topic < 0)
DDS_FATAL("dds_create_topic: %s\n", dds_strretcode(-topic));
dds_delete_qos (qos);

/* A DDS Publisher is created on the domain participant. */

Expand All @@ -185,7 +188,6 @@ static dds_entity_t prepare_dds(dds_entity_t *wr, dds_entity_t *rd, dds_entity_t
/* A DDS DataWriter is created on the Publisher & Topic with a modififed Qos. */

qos = dds_create_qos ();
dds_qset_reliability (qos, DDS_RELIABILITY_RELIABLE, DDS_SECS(10));
dds_qset_writer_data_lifecycle (qos, false);
*wr = dds_create_writer (publisher, topic, qos, NULL);
if (*wr < 0)
Expand All @@ -204,12 +206,9 @@ static dds_entity_t prepare_dds(dds_entity_t *wr, dds_entity_t *rd, dds_entity_t

/* A DDS DataReader is created on the Subscriber & Topic with a modified QoS. */

qos = dds_create_qos ();
dds_qset_reliability (qos, DDS_RELIABILITY_RELIABLE, DDS_SECS(10));
*rd = dds_create_reader (subscriber, topic, qos, rdlist);
*rd = dds_create_reader (subscriber, topic, NULL, rdlist);
if (*rd < 0)
DDS_FATAL("dds_create_reader: %s\n", dds_strretcode(-*rd));
dds_delete_qos (qos);

waitSet = dds_create_waitset (participant);
if (rdlist == NULL) {
Expand Down
16 changes: 8 additions & 8 deletions examples/throughput/publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static dds_entity_t prepare_dds(dds_entity_t *writer, const char *partitionName)
dds_entity_t publisher;
const char *pubParts[1];
dds_qos_t *pubQos;
dds_qos_t *dwQos;
dds_qos_t *tQos;

/* A domain participant is created for the default domain. */
participant = dds_create_participant (DDS_DOMAIN_DEFAULT, NULL, NULL);
Expand All @@ -151,7 +151,11 @@ static dds_entity_t prepare_dds(dds_entity_t *writer, const char *partitionName)
dds_write_set_batch (true);

/* A topic is created for our sample type on the domain participant. */
topic = dds_create_topic (participant, &ThroughputModule_DataType_desc, "Throughput", NULL, NULL);
tQos = dds_create_qos ();
dds_qset_reliability (tQos, DDS_RELIABILITY_RELIABLE, DDS_SECS (10));
dds_qset_history (tQos, DDS_HISTORY_KEEP_ALL, 0);
dds_qset_resource_limits (tQos, MAX_SAMPLES, DDS_LENGTH_UNLIMITED, DDS_LENGTH_UNLIMITED);
topic = dds_create_topic (participant, &ThroughputModule_DataType_desc, "Throughput", tQos, NULL);
if (topic < 0)
DDS_FATAL("dds_create_topic: %s\n", dds_strretcode(-topic));

Expand All @@ -165,14 +169,10 @@ static dds_entity_t prepare_dds(dds_entity_t *writer, const char *partitionName)
dds_delete_qos (pubQos);

/* A DataWriter is created on the publisher. */
dwQos = dds_create_qos ();
dds_qset_reliability (dwQos, DDS_RELIABILITY_RELIABLE, DDS_SECS (10));
dds_qset_history (dwQos, DDS_HISTORY_KEEP_ALL, 0);
dds_qset_resource_limits (dwQos, MAX_SAMPLES, DDS_LENGTH_UNLIMITED, DDS_LENGTH_UNLIMITED);
*writer = dds_create_writer (publisher, topic, dwQos, NULL);
*writer = dds_create_writer (publisher, topic, NULL, NULL);
if (*writer < 0)
DDS_FATAL("dds_create_writer: %s\n", dds_strretcode(-*writer));
dds_delete_qos (dwQos);
dds_delete_qos (tQos);

return participant;
}
Expand Down
15 changes: 7 additions & 8 deletions examples/throughput/subscriber.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ static dds_entity_t prepare_dds(dds_entity_t *reader, const char *partitionName)
int32_t maxSamples = 4000;
const char *subParts[1];
dds_qos_t *subQos = dds_create_qos ();
dds_qos_t *drQos = dds_create_qos ();
dds_qos_t *tQos = dds_create_qos ();

/* A Participant is created for the default domain. */

Expand All @@ -325,7 +325,10 @@ static dds_entity_t prepare_dds(dds_entity_t *reader, const char *partitionName)

/* A Topic is created for our sample type on the domain participant. */

topic = dds_create_topic (participant, &ThroughputModule_DataType_desc, "Throughput", NULL, NULL);
dds_qset_reliability (tQos, DDS_RELIABILITY_RELIABLE, DDS_SECS (10));
dds_qset_history (tQos, DDS_HISTORY_KEEP_ALL, 0);
dds_qset_resource_limits (tQos, maxSamples, DDS_LENGTH_UNLIMITED, DDS_LENGTH_UNLIMITED);
topic = dds_create_topic (participant, &ThroughputModule_DataType_desc, "Throughput", tQos, NULL);
if (topic < 0)
DDS_FATAL("dds_create_topic: %s\n", dds_strretcode(-topic));

Expand All @@ -340,10 +343,6 @@ static dds_entity_t prepare_dds(dds_entity_t *reader, const char *partitionName)

/* A Reader is created on the Subscriber & Topic with a modified Qos. */

dds_qset_reliability (drQos, DDS_RELIABILITY_RELIABLE, DDS_SECS (10));
dds_qset_history (drQos, DDS_HISTORY_KEEP_ALL, 0);
dds_qset_resource_limits (drQos, maxSamples, DDS_LENGTH_UNLIMITED, DDS_LENGTH_UNLIMITED);

rd_listener = dds_create_listener(NULL);
dds_lset_data_available(rd_listener, data_available_handler);

Expand All @@ -364,7 +363,7 @@ static dds_entity_t prepare_dds(dds_entity_t *reader, const char *partitionName)
samples[i] = &data[i];
}

*reader = dds_create_reader (subscriber, topic, drQos, pollingDelay < 0 ? rd_listener : NULL);
*reader = dds_create_reader (subscriber, topic, NULL, pollingDelay < 0 ? rd_listener : NULL);
if (*reader < 0)
DDS_FATAL("dds_create_reader: %s\n", dds_strretcode(-*reader));

Expand All @@ -375,7 +374,7 @@ static dds_entity_t prepare_dds(dds_entity_t *reader, const char *partitionName)
DDS_FATAL("dds_waitset_attach: %s\n", dds_strretcode(-status));
}

dds_delete_qos (drQos);
dds_delete_qos (tQos);
dds_delete_listener(rd_listener);

return participant;
Expand Down

0 comments on commit 8b82dc5

Please sign in to comment.