Skip to content

Commit 5a12fc4

Browse files
committed
Update
Signed-off-by: Pablo Garrido <pablogs9@gmail.com>
1 parent 1b4361d commit 5a12fc4

42 files changed

Lines changed: 294 additions & 288 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

rmw_microxrcedds_c/include/rmw_microros/error_handling.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,21 @@ typedef enum
3434
{
3535
RMW_UROS_ERROR_ON_UNKNOWN = 0,
3636
RMW_UROS_ERROR_ON_NODE,
37-
RMW_UROS_ERROR_ON_TOPIC,
3837
RMW_UROS_ERROR_ON_SERVICE,
3938
RMW_UROS_ERROR_ON_CLIENT,
4039
RMW_UROS_ERROR_ON_SUBSCRIPTION,
41-
RMW_UROS_ERROR_ON_PUBLISHER
40+
RMW_UROS_ERROR_ON_PUBLISHER,
41+
RMW_UROS_ERROR_ON_GRAPH,
42+
RMW_UROS_ERROR_ON_GUARD_CONDITION,
43+
RMW_UROS_ERROR_ON_TOPIC
4244
} rmw_uros_error_entity_type_t;
4345

4446
typedef enum
4547
{
4648
RMW_UROS_ERROR_ENTITY_CREATION = 0,
4749
RMW_UROS_ERROR_ENTITY_DESTRUCTION,
50+
RMW_UROS_ERROR_CHECK,
51+
RMW_UROS_ERROR_NOT_IMPLEMENTED,
4852
RMW_UROS_ERROR_MIDDLEWARE_ALLOCATION,
4953
} rmw_uros_error_source_t;
5054

rmw_microxrcedds_c/include/rmw_microxrcedds_c/rmw_c_macros.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
#define RMW_MICROXRCEDDS_C__RMW_C_MACROS_H_
1717

1818
#include <rmw/error_handling.h>
19+
#include <rmw_microros_internal/identifiers.h>
1920

20-
#define RMW_CHECK_TYPE_IDENTIFIERS_MATCH(ElementName, ElementTypeID, ExpectedTypeID, OnFailure) \
21+
#define RMW_CHECK_TYPE_IDENTIFIERS_MATCH(identifier, ret_on_failure) \
2122
{ \
22-
if (strcmp(ElementTypeID, ExpectedTypeID) != 0) { \
23+
if (NULL != identifier && strcmp(identifier, eprosima_microxrcedds_identifier) != 0) { \
2324
RMW_SET_ERROR_MSG("Implementation identifiers does not match"); \
24-
OnFailure; \
25+
return ret_on_failure; \
2526
} \
2627
}
2728

rmw_microxrcedds_c/src/callbacks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
#include <rmw_microros_internal/callbacks.h>
16-
#include <rmw_microros_internal/memory_error_handling_internal.h>
16+
#include "./rmw_microros_internal/error_handling_internal.h"
1717

1818
void on_status(
1919
struct uxrSession * session,

rmw_microxrcedds_c/src/rmw_client.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,20 @@ rmw_create_client(
3535
{
3636
rmw_client_t * rmw_client = NULL;
3737
if (!node) {
38-
RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_ON_CLIENT, RMW_UROS_ERROR_ENTITY_CREATION, "node handle is null", 0);
38+
RMW_UROS_TRACE_MESSAGE("node handle is null")
3939
} else if (!type_support) {
40-
RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_ON_CLIENT, RMW_UROS_ERROR_ENTITY_CREATION, "type support is null", 0);
40+
RMW_UROS_TRACE_MESSAGE("type support is null")
4141
} else if (!is_uxrce_rmw_identifier_valid(node->implementation_identifier)) {
42-
RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_ON_CLIENT, RMW_UROS_ERROR_ENTITY_CREATION, "node handle not from this implementation", 0);
42+
RMW_UROS_TRACE_MESSAGE("node handle not from this implementation")
4343
} else if (!service_name || strlen(service_name) == 0) {
44-
RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_ON_CLIENT, RMW_UROS_ERROR_ENTITY_CREATION, "service name is null or empty string", 0);
44+
RMW_UROS_TRACE_MESSAGE("service name is null or empty string")
4545
} else if (!qos_policies) {
46-
RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_ON_CLIENT, RMW_UROS_ERROR_ENTITY_CREATION, "qos_profile is null", 0);
46+
RMW_UROS_TRACE_MESSAGE("qos_profile is null")
4747
} else {
4848
rmw_uxrce_node_t * custom_node = (rmw_uxrce_node_t *)node->data;
4949
rmw_uxrce_mempool_item_t * memory_node = get_memory(&client_memory);
5050
if (!memory_node) {
51-
RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_ON_CLIENT, RMW_UROS_ERROR_ENTITY_CREATION, "Not available memory node", 0);
51+
RMW_UROS_TRACE_MESSAGE("Not available memory node")
5252
return NULL;
5353
}
5454
rmw_uxrce_client_t * custom_client = (rmw_uxrce_client_t *)memory_node->data;
@@ -58,7 +58,7 @@ rmw_create_client(
5858
rmw_client->implementation_identifier = rmw_get_implementation_identifier();
5959
rmw_client->service_name = custom_client->service_name;
6060
if ((strlen(service_name) + 1 ) > sizeof(custom_client->service_name)) {
61-
RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_ON_CLIENT, RMW_UROS_ERROR_ENTITY_CREATION, "failed to allocate string", 0);
61+
RMW_UROS_TRACE_MESSAGE("failed to allocate string")
6262
goto fail;
6363
}
6464

@@ -80,15 +80,15 @@ rmw_create_client(
8080
}
8181
#endif /* ifdef ROSIDL_TYPESUPPORT_MICROXRCEDDS_CPP__IDENTIFIER_VALUE */
8282
if (NULL == type_support_xrce) {
83-
RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_ON_CLIENT, RMW_UROS_ERROR_ENTITY_CREATION, "Undefined type support", 0);
83+
RMW_UROS_TRACE_MESSAGE("Undefined type support")
8484
goto fail;
8585
}
8686

8787
custom_client->type_support_callbacks =
8888
(const service_type_support_callbacks_t *)type_support_xrce->data;
8989

9090
if (custom_client->type_support_callbacks == NULL) {
91-
RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_ON_CLIENT, RMW_UROS_ERROR_ENTITY_CREATION, "type support data is NULL", 0);
91+
RMW_UROS_TRACE_MESSAGE("type support data is NULL")
9292
goto fail;
9393
}
9494

@@ -109,7 +109,7 @@ rmw_create_client(
109109
custom_client->type_support_callbacks, qos_policies, rmw_uxrce_entity_naming_buffer,
110110
sizeof(rmw_uxrce_entity_naming_buffer)))
111111
{
112-
RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_ON_CLIENT, RMW_UROS_ERROR_ENTITY_CREATION, "failed to generate xml request for client creation", 0);
112+
RMW_UROS_TRACE_MESSAGE("failed to generate xml request for client creation")
113113
goto fail;
114114
}
115115
client_req = uxr_buffer_create_requester_xml(
@@ -190,22 +190,22 @@ rmw_destroy_client(
190190
{
191191
rmw_ret_t result_ret = RMW_RET_OK;
192192
if (!node) {
193-
RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_ON_CLIENT, RMW_UROS_ERROR_ENTITY_DESTRUCTION, "node handle is null", 0);
193+
RMW_UROS_TRACE_MESSAGE("node handle is null")
194194
result_ret = RMW_RET_ERROR;
195195
} else if (!is_uxrce_rmw_identifier_valid(node->implementation_identifier)) {
196-
RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_ON_CLIENT, RMW_UROS_ERROR_ENTITY_DESTRUCTION, "node handle not from this implementation", 0);
196+
RMW_UROS_TRACE_MESSAGE("node handle not from this implementation")
197197
result_ret = RMW_RET_ERROR;
198198
} else if (!node->data) {
199-
RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_ON_CLIENT, RMW_UROS_ERROR_ENTITY_DESTRUCTION, "node imp is null", 0);
199+
RMW_UROS_TRACE_MESSAGE("node imp is null")
200200
result_ret = RMW_RET_ERROR;
201201
} else if (!client) {
202-
RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_ON_CLIENT, RMW_UROS_ERROR_ENTITY_DESTRUCTION, "client handle is null", 0);
202+
RMW_UROS_TRACE_MESSAGE("client handle is null")
203203
result_ret = RMW_RET_ERROR;
204204
} else if (!is_uxrce_rmw_identifier_valid(client->implementation_identifier)) {
205-
RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_ON_CLIENT, RMW_UROS_ERROR_ENTITY_DESTRUCTION, "client handle not from this implementation", 0);
205+
RMW_UROS_TRACE_MESSAGE("client handle not from this implementation")
206206
result_ret = RMW_RET_ERROR;
207207
} else if (!client->data) {
208-
RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_ON_CLIENT, RMW_UROS_ERROR_ENTITY_DESTRUCTION, "client imp is null", 0);
208+
RMW_UROS_TRACE_MESSAGE("client imp is null")
209209
result_ret = RMW_RET_ERROR;
210210
} else {
211211
rmw_uxrce_node_t * custom_node = (rmw_uxrce_node_t *)node->data;

rmw_microxrcedds_c/src/rmw_compare_gids_equal.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#include <rmw/rmw.h>
1616
#include <rmw/error_handling.h>
1717

18+
#include <rmw_microxrcedds_c/rmw_c_macros.h>
19+
#include "./rmw_microros_internal/error_handling_internal.h"
20+
1821
rmw_ret_t
1922
rmw_compare_gids_equal(
2023
const rmw_gid_t * gid1,
@@ -24,13 +27,12 @@ rmw_compare_gids_equal(
2427
// Check
2528
RMW_CHECK_ARGUMENT_FOR_NULL(gid1, RMW_RET_INVALID_ARGUMENT);
2629
RMW_CHECK_ARGUMENT_FOR_NULL(gid2, RMW_RET_INVALID_ARGUMENT);
27-
if (gid1->implementation_identifier != rmw_get_implementation_identifier()) {
28-
RMW_SET_ERROR_MSG("publisher handle not from this implementation");
29-
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION;
30-
} else if (gid2->implementation_identifier != rmw_get_implementation_identifier()) {
31-
RMW_SET_ERROR_MSG("publisher handle not from this implementation");
32-
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION;
33-
}
30+
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
31+
gid1->implementation_identifier,
32+
RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
33+
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
34+
gid2->implementation_identifier,
35+
RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
3436

3537
*result = memcmp(gid1->data, gid2->data, sizeof(rmw_gid_t)) == 0;
3638

rmw_microxrcedds_c/src/rmw_count.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "./rmw_microros_internal/types.h"
2323
#include "./rmw_microros_internal/identifiers.h"
24+
#include "./rmw_microros_internal/error_handling_internal.h"
2425

2526
#ifdef RMW_UXRCE_GRAPH
2627
#include "./rmw_microros_internal/rmw_graph.h"
@@ -37,8 +38,8 @@ __rmw_count_entities(
3738
// Perform RMW checks
3839
RMW_CHECK_ARGUMENT_FOR_NULL(node, RMW_RET_INVALID_ARGUMENT);
3940
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
40-
node, node->implementation_identifier,
41-
eprosima_microxrcedds_identifier, return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
41+
node->implementation_identifier,
42+
RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
4243
RMW_CHECK_ARGUMENT_FOR_NULL(topic_name, RMW_RET_INVALID_ARGUMENT);
4344
RMW_CHECK_ARGUMENT_FOR_NULL(count, RMW_RET_INVALID_ARGUMENT);
4445
// Set count to zero, just in case it was holding another value
@@ -98,8 +99,7 @@ rmw_count_publishers(
9899
(void)node;
99100
(void)topic_name;
100101
(void)count;
101-
RMW_SET_ERROR_MSG(
102-
"Function not available; enable RMW_UXRCE_GRAPH configuration profile before using");
102+
RMW_UROS_TRACE_MESSAGE("Function not available; enable RMW_UXRCE_GRAPH configuration profile before using");
103103
return RMW_RET_UNSUPPORTED;
104104
#endif // RMW_UXRCE_GRAPH
105105
}
@@ -120,8 +120,7 @@ rmw_count_subscribers(
120120
(void)node;
121121
(void)topic_name;
122122
(void)count;
123-
RMW_SET_ERROR_MSG(
124-
"Function not available; enable RMW_UXRCE_GRAPH configuration profile before using");
123+
RMW_UROS_TRACE_MESSAGE("Function not available; enable RMW_UXRCE_GRAPH configuration profile before using");
125124
return RMW_RET_UNSUPPORTED;
126125
#endif // RMW_UXRCE_GRAPH
127126
}

rmw_microxrcedds_c/src/rmw_event.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
#include <rmw/event.h>
1616

17+
#include "./rmw_microros_internal/error_handling_internal.h"
18+
1719
rmw_ret_t
1820
rmw_publisher_event_init(
1921
rmw_event_t * rmw_event,
@@ -23,7 +25,7 @@ rmw_publisher_event_init(
2325
(void)rmw_event;
2426
(void)publisher;
2527
(void)event_type;
26-
RMW_SET_ERROR_MSG("function not implemented");
28+
RMW_UROS_TRACE_MESSAGE("function not implemented")
2729
return RMW_RET_UNSUPPORTED;
2830
}
2931

@@ -36,6 +38,6 @@ rmw_subscription_event_init(
3638
(void)rmw_event;
3739
(void)subscription;
3840
(void)event_type;
39-
RMW_SET_ERROR_MSG("function not implemented");
41+
RMW_UROS_TRACE_MESSAGE("function not implemented")
4042
return RMW_RET_UNSUPPORTED;
4143
}

rmw_microxrcedds_c/src/rmw_get_endpoint_network_flow.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <rmw/types.h>
1717
#include <rmw/get_network_flow_endpoints.h>
1818

19+
#include "./rmw_microros_internal/error_handling_internal.h"
20+
1921
rmw_ret_t
2022
rmw_publisher_get_network_flow_endpoints(
2123
const rmw_publisher_t * publisher,
@@ -26,7 +28,7 @@ rmw_publisher_get_network_flow_endpoints(
2628
(void) allocator;
2729
(void) network_flow_endpoint_array;
2830

29-
RMW_SET_ERROR_MSG("function not implemented");
31+
RMW_UROS_TRACE_MESSAGE("function not implemented")
3032
return RMW_RET_UNSUPPORTED;
3133
}
3234

@@ -40,6 +42,6 @@ rmw_subscription_get_network_flow_endpoints(
4042
(void) allocator;
4143
(void) network_flow_endpoint_array;
4244

43-
RMW_SET_ERROR_MSG("function not implemented");
45+
RMW_UROS_TRACE_MESSAGE("function not implemented")
4446
return RMW_RET_UNSUPPORTED;
4547
}

rmw_microxrcedds_c/src/rmw_get_gid_for_publisher.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,26 @@
1313
// limitations under the License.
1414

1515
#include <rmw/rmw.h>
16+
#include <rmw_microxrcedds_c/rmw_c_macros.h>
1617

1718
#include "./rmw_microros_internal/types.h"
19+
#include "./rmw_microros_internal/error_handling_internal.h"
1820

1921
rmw_ret_t
2022
rmw_get_gid_for_publisher(
2123
const rmw_publisher_t * publisher,
2224
rmw_gid_t * gid)
2325
{
24-
// Check
2526
RMW_CHECK_ARGUMENT_FOR_NULL(publisher, RMW_RET_INVALID_ARGUMENT);
2627
RMW_CHECK_ARGUMENT_FOR_NULL(gid, RMW_RET_INVALID_ARGUMENT);
27-
if (publisher->implementation_identifier != rmw_get_implementation_identifier()) {
28-
RMW_SET_ERROR_MSG("publisher handle not from this implementation");
29-
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION;
30-
}
28+
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
29+
publisher->implementation_identifier,
30+
RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
3131

32-
// Do
3332
rmw_uxrce_publisher_t * custom_publisher = (rmw_uxrce_publisher_t *)publisher->data;
3433

3534
if (sizeof(uxrObjectId) > RMW_GID_STORAGE_SIZE) {
36-
RMW_SET_ERROR_MSG("Not enough memory for impl ids");
35+
RMW_UROS_TRACE_MESSAGE("Not enough memory for impl ids")
3736
return RMW_RET_ERROR;
3837
}
3938

rmw_microxrcedds_c/src/rmw_get_topic_endpoint_info.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "./rmw_microros_internal/types.h"
2626
#include "./rmw_microros_internal/identifiers.h"
27+
#include "./rmw_microros_internal/error_handling_internal.h"
2728

2829
#ifdef RMW_UXRCE_GRAPH
2930
#include "./rmw_microros_internal/rmw_graph.h"
@@ -70,8 +71,8 @@ __rmw_get_endpoint_info_by_topic(
7071
// Perform RMW checks
7172
RMW_CHECK_ARGUMENT_FOR_NULL(node, RMW_RET_INVALID_ARGUMENT);
7273
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
73-
node, node->implementation_identifier,
74-
eprosima_microxrcedds_identifier, return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
74+
node->implementation_identifier,
75+
RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
7576
RCUTILS_CHECK_ALLOCATOR_WITH_MSG(
7677
allocator, "Allocator argument is invalid",
7778
return RMW_RET_INVALID_ARGUMENT);
@@ -206,8 +207,7 @@ rmw_get_publishers_info_by_topic(
206207
(void)topic_name;
207208
(void)no_mangle;
208209
(void)publishers_info;
209-
RMW_SET_ERROR_MSG(
210-
"Function not available; enable RMW_UXRCE_GRAPH configuration profile before using");
210+
RMW_UROS_TRACE_MESSAGE("Function not available; enable RMW_UXRCE_GRAPH configuration profile before using");
211211
return RMW_RET_UNSUPPORTED;
212212
#endif // RMW_UXRCE_GRAPH
213213
}
@@ -234,8 +234,7 @@ rmw_get_subscriptions_info_by_topic(
234234
(void)topic_name;
235235
(void)no_mangle;
236236
(void)subscriptions_info;
237-
RMW_SET_ERROR_MSG(
238-
"Function not available; enable RMW_UXRCE_GRAPH configuration profile before using");
237+
RMW_UROS_TRACE_MESSAGE("Function not available; enable RMW_UXRCE_GRAPH configuration profile before using");
239238
return RMW_RET_UNSUPPORTED;
240239
#endif // RMW_UXRCE_GRAPH
241240
}

0 commit comments

Comments
 (0)