Skip to content

Commit 539a0f1

Browse files
committed
Added return value handling for writer and reader creation
1 parent 1a5f9ff commit 539a0f1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/modules/uxrce_dds_client/dds_topics.h.em

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ void SendTopicsSubs::update(uxrSession *session, uxrStreamId reliable_out_stream
8787

8888
if (@(pub['topic_simple'])_data_writer.id == UXR_INVALID_ID) {
8989
// data writer not created yet
90-
create_data_writer(session, reliable_out_stream_id, participant_id, ORB_ID::@(pub['topic_simple']), client_namespace, "@(pub['topic_name'])", "@(pub['dds_type'])", @(pub['topic_simple'])_data_writer);
90+
if (!create_data_writer(session, reliable_out_stream_id, participant_id, ORB_ID::@(pub['topic_simple']), client_namespace, "@(pub['topic_name'])", "@(pub['dds_type'])", @(pub['topic_simple'])_data_writer)) {
91+
@(pub['topic_simple'])_data_writer.id = UXR_INVALID_ID;
92+
}
9193
}
9294

9395
if (@(pub['topic_simple'])_data_writer.id != UXR_INVALID_ID) {
@@ -107,7 +109,6 @@ void SendTopicsSubs::update(uxrSession *session, uxrStreamId reliable_out_stream
107109
} else {
108110
//PX4_ERR("Error UXR_INVALID_ID @(pub['topic_simple'])");
109111
}
110-
111112
}
112113
@[ end for]@
113114
}
@@ -152,14 +153,15 @@ static void on_topic_update(uxrSession *session, uxrObjectId object_id, uint16_t
152153

153154
bool RcvTopicsPubs::init(uxrSession *session, uxrStreamId reliable_out_stream_id, uxrStreamId reliable_in_stream_id, uxrStreamId best_effort_in_stream_id, uxrObjectId participant_id, const char *client_namespace)
154155
{
156+
bool ret = true;
155157
@[ for idx, sub in enumerate(subscriptions)]@
156158
{
157159
uint16_t queue_depth = uORB::DefaultQueueSize<@(sub['simple_base_type'])_s>::value * 2; // use a bit larger queue size than internal
158-
create_data_reader(session, reliable_out_stream_id, best_effort_in_stream_id, participant_id, @(idx), client_namespace, "@(sub['topic_name'])", "@(sub['dds_type'])", queue_depth);
160+
ret = create_data_reader(session, reliable_out_stream_id, best_effort_in_stream_id, participant_id, @(idx), client_namespace, "@(sub['topic_name'])", "@(sub['dds_type'])", queue_depth);
159161
}
160162
@[ end for]@
161163

162164
uxr_set_topic_callback(session, on_topic_update, this);
163165

164-
return true;
166+
return ret;
165167
}

0 commit comments

Comments
 (0)