Skip to content

Commit fe989a1

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

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

rmw_microxrcedds_c/include/rmw_microros/error_handling.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,15 @@ typedef struct
5858
const message_type_support_callbacks_t * message_callbacks;
5959
const service_type_support_callbacks_t * service_callbacks;
6060
} type_support;
61+
const char * description;
6162
} rmw_uros_error_context_t;
6263

6364
typedef void (* rmw_uros_error_handling)(
6465
const rmw_uros_error_source_t source,
6566
const rmw_uros_error_entity_type_t entity,
66-
const rmw_uros_error_context_t context);
67+
const rmw_uros_error_context_t context,
68+
const char * file,
69+
const int line);
6770

6871
/** \addtogroup rmw micro-ROS RMW API
6972
* @{

rmw_microxrcedds_c/src/callbacks.c

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

1515
#include <rmw_microros_internal/callbacks.h>
1616
#include <rmw_microros_internal/memory_error_handling_internal.h>
17-
#include <rmw/error_handling.h>
1817

1918
void on_status(
2019
struct uxrSession * session,
@@ -76,9 +75,9 @@ void on_topic(
7675
custom_subscription, custom_subscription->qos);
7776
if (!memory_node) {
7877
UXR_UNLOCK(&static_buffer_memory.mutex);
79-
RMW_SET_ERROR_MSG("Not available static buffer memory node");
8078
RMW_UROS_TRACE_ERROR(
8179
RMW_UROS_ERROR_ON_SUBSCRIPTION, RMW_UROS_ERROR_MIDDLEWARE_ALLOCATION,
80+
"Not available static buffer memory node in on_topic callback",
8281
.node = custom_subscription->owner_node->node_name,
8382
.namespace = custom_subscription->owner_node->node_namespace,
8483
.topic_name = custom_subscription->topic_name, .ucdr = ub,
@@ -135,9 +134,9 @@ void on_request(
135134
custom_service, custom_service->qos);
136135
if (!memory_node) {
137136
UXR_UNLOCK(&static_buffer_memory.mutex);
138-
RMW_SET_ERROR_MSG("Not available static buffer memory node");
139137
RMW_UROS_TRACE_ERROR(
140138
RMW_UROS_ERROR_ON_SERVICE, RMW_UROS_ERROR_MIDDLEWARE_ALLOCATION,
139+
"Not available static buffer memory node in on_request callback",
141140
.node = custom_service->owner_node->node_name,
142141
.namespace = custom_service->owner_node->node_namespace,
143142
.topic_name = custom_service->service_name, .ucdr = ub,
@@ -196,14 +195,14 @@ void on_reply(
196195
custom_client, custom_client->qos);
197196
if (!memory_node) {
198197
UXR_UNLOCK(&static_buffer_memory.mutex);
199-
RMW_SET_ERROR_MSG("Not available static buffer memory node");
200198
RMW_UROS_TRACE_ERROR(
201199
RMW_UROS_ERROR_ON_CLIENT, RMW_UROS_ERROR_MIDDLEWARE_ALLOCATION,
200+
"Not available static buffer memory node in on_reply callback",
202201
.node = custom_client->owner_node->node_name,
203202
.namespace = custom_client->owner_node->node_namespace,
204203
.topic_name = custom_client->service_name, .ucdr = ub,
205204
.size = length,
206-
.type_support.service_callbacks = custom_service->type_support_callbacks);
205+
.type_support.service_callbacks = custom_client->type_support_callbacks);
207206
return;
208207
}
209208

rmw_microxrcedds_c/src/rmw_microros_internal/memory_error_handling_internal.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ extern "C"
3030
#ifdef RMW_UROS_ERROR_HANDLING
3131
extern rmw_uros_error_handling error_callback;
3232

33-
// #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( \
35-
entity, source, (rmw_uros_error_context_t) {__VA_ARGS__});}
33+
#define RMW_UROS_TRACE_ERROR(entity, source, desc, ...) \
34+
if (NULL != error_callback) { \
35+
rmw_uros_error_context_t ctx = {__VA_ARGS__}; \
36+
ctx.description = desc; \
37+
RMW_SET_ERROR_MSG(desc); \
38+
error_callback(entity, source, ctx, __FILE__, __LINE__); \
39+
}
3640

3741
#else
3842
#define RMW_UROS_TRACE_ERROR(source, context)

0 commit comments

Comments
 (0)