Skip to content

Commit e08bac2

Browse files
committed
Update
Signed-off-by: Pablo Garrido <pablogs9@gmail.com>
1 parent 0f961ce commit e08bac2

3 files changed

Lines changed: 40 additions & 13 deletions

File tree

rmw_microxrcedds_c/include/rmw_microros/error_handling.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@
1919
#ifndef RMW_MICROROS__ERROR_HANDLING_H_
2020
#define RMW_MICROROS__ERROR_HANDLING_H_
2121

22+
#ifdef RMW_UROS_ERROR_HANDLING
23+
2224
#include <ucdr/microcdr.h>
25+
#include <rosidl_typesupport_microxrcedds_c/message_type_support.h>
26+
#include <rosidl_typesupport_microxrcedds_c/service_type_support.h>
2327

2428
#if defined(__cplusplus)
2529
extern "C"
2630
{
2731
#endif // if defined(__cplusplus)
2832

29-
#ifdef RMW_UROS_ERROR_HANDLING
30-
3133
typedef enum
3234
{
3335
RMW_UROS_ERROR_ON_UNKNOWN = 0,
@@ -39,17 +41,23 @@ typedef enum
3941
RMW_UROS_ERROR_ON_PUBLISHER
4042
} rmw_uros_error_entity_type_t;
4143

42-
typedef enum {
44+
typedef enum
45+
{
4346
RMW_UROS_ERROR_ENTITY_CREATION = 0,
4447
RMW_UROS_ERROR_MIDDLEWARE_ALLOCATION,
4548
} rmw_uros_error_source_t;
4649

47-
typedef struct {
50+
typedef struct
51+
{
4852
const char * node;
4953
const char * namespace;
5054
const char * topic_name;
5155
const ucdrBuffer * ucdr;
5256
const size_t size;
57+
union {
58+
const message_type_support_callbacks_t * message_callbacks;
59+
const service_type_support_callbacks_t * service_callbacks;
60+
} type_support;
5361
} rmw_uros_error_context_t;
5462

5563
typedef void (* rmw_uros_error_handling)(
@@ -69,12 +77,12 @@ typedef void (* rmw_uros_error_handling)(
6977
void rmw_uros_set_error_handling_callback(
7078
rmw_uros_error_handling error_cb);
7179

72-
#endif // RMW_UROS_ERROR_HANDLING
73-
7480
/** @}*/
7581

7682
#if defined(__cplusplus)
7783
}
7884
#endif // if defined(__cplusplus)
7985

86+
#endif // RMW_UROS_ERROR_HANDLING
87+
8088
#endif // RMW_MICROROS__ERROR_HANDLING_H_

rmw_microxrcedds_c/src/callbacks.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,15 @@ void on_topic(
7575
rmw_uxrce_mempool_item_t * memory_node = rmw_uxrce_get_static_input_buffer_for_entity(
7676
custom_subscription, custom_subscription->qos);
7777
if (!memory_node) {
78-
RMW_SET_ERROR_MSG("Not available static buffer memory node");
7978
UXR_UNLOCK(&static_buffer_memory.mutex);
80-
RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_ON_SUBSCRIPTION, RMW_UROS_ERROR_MIDDLEWARE_ALLOCATION, .node = custom_subscription->owner_node->node_name, .namespace = custom_subscription->owner_node->node_namespace, .topic_name = custom_subscription->topic_name, .ucdr = ub, .size = length);
79+
RMW_SET_ERROR_MSG("Not available static buffer memory node");
80+
RMW_UROS_TRACE_ERROR(
81+
RMW_UROS_ERROR_ON_SUBSCRIPTION, RMW_UROS_ERROR_MIDDLEWARE_ALLOCATION,
82+
.node = custom_subscription->owner_node->node_name,
83+
.namespace = custom_subscription->owner_node->node_namespace,
84+
.topic_name = custom_subscription->topic_name, .ucdr = ub,
85+
.size = length,
86+
.type_support.message_callbacks = custom_subscription->type_support_callbacks);
8187
return;
8288
}
8389

@@ -128,9 +134,15 @@ void on_request(
128134
rmw_uxrce_mempool_item_t * memory_node = rmw_uxrce_get_static_input_buffer_for_entity(
129135
custom_service, custom_service->qos);
130136
if (!memory_node) {
131-
RMW_SET_ERROR_MSG("Not available static buffer memory node");
132137
UXR_UNLOCK(&static_buffer_memory.mutex);
133-
// RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_MIDDLEWARE_ALLOCATION, .node = custom_service->owner_node->node_name, .namespace = custom_service->owner_node->node_namespace, .topic = custom_subscription->topic_name, .ucdr = ub, .size = length);
138+
RMW_SET_ERROR_MSG("Not available static buffer memory node");
139+
RMW_UROS_TRACE_ERROR(
140+
RMW_UROS_ERROR_ON_SERVICE, RMW_UROS_ERROR_MIDDLEWARE_ALLOCATION,
141+
.node = custom_service->owner_node->node_name,
142+
.namespace = custom_service->owner_node->node_namespace,
143+
.topic_name = custom_service->service_name, .ucdr = ub,
144+
.size = length,
145+
.type_support.service_callbacks = custom_service->type_support_callbacks);
134146
return;
135147
}
136148

@@ -183,9 +195,15 @@ void on_reply(
183195
rmw_uxrce_mempool_item_t * memory_node = rmw_uxrce_get_static_input_buffer_for_entity(
184196
custom_client, custom_client->qos);
185197
if (!memory_node) {
186-
RMW_SET_ERROR_MSG("Not available static buffer memory node");
187198
UXR_UNLOCK(&static_buffer_memory.mutex);
188-
// RMW_UROS_TRACE_ERROR(RMW_UROS_ERROR_MIDDLEWARE_ALLOCATION, ub, length);
199+
RMW_SET_ERROR_MSG("Not available static buffer memory node");
200+
RMW_UROS_TRACE_ERROR(
201+
RMW_UROS_ERROR_ON_CLIENT, RMW_UROS_ERROR_MIDDLEWARE_ALLOCATION,
202+
.node = custom_client->owner_node->node_name,
203+
.namespace = custom_client->owner_node->node_namespace,
204+
.topic_name = custom_client->service_name, .ucdr = ub,
205+
.size = length,
206+
.type_support.service_callbacks = custom_service->type_support_callbacks);
189207
return;
190208
}
191209

rmw_microxrcedds_c/src/rmw_microros_internal/memory_error_handling_internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ extern "C"
3131
extern rmw_uros_error_handling error_callback;
3232

3333
// #define RMW_UROS_TRACE_ERROR(source, context) if(NULL != error_callback) {error_callback(source, (rmw_uros_error_context_t) context);}
34-
#define RMW_UROS_TRACE_ERROR(entity, source, ...) if(NULL != error_callback) {error_callback(entity, source, (rmw_uros_error_context_t){__VA_ARGS__});}
34+
#define RMW_UROS_TRACE_ERROR(entity, source, ...) if (NULL != error_callback) {error_callback( \
35+
entity, source, (rmw_uros_error_context_t) {__VA_ARGS__});}
3536

3637
#else
3738
#define RMW_UROS_TRACE_ERROR(source, context)

0 commit comments

Comments
 (0)