Skip to content

Commit 145df52

Browse files
committed
Initial
Signed-off-by: Pablo Garrido <pablogs9@gmail.com>
1 parent 1660762 commit 145df52

4 files changed

Lines changed: 93 additions & 1 deletion

File tree

rmw_microxrcedds_c/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ set(SRCS
190190
src/rmw_microros/time_sync.c
191191
src/rmw_microros/ping.c
192192
src/rmw_microros/timing.c
193+
src/rmw_microros/memory_error_handling.c
193194
$<$<OR:$<BOOL:${RMW_UXRCE_TRANSPORT_UDP}>,$<BOOL:${RMW_UXRCE_TRANSPORT_TCP}>>:src/rmw_microros/discovery.c>
194195
$<$<BOOL:${RMW_UXRCE_TRANSPORT_CUSTOM}>:src/rmw_microros/custom_transport.c>
195196
$<$<BOOL:${RMW_UXRCE_GRAPH}>:src/rmw_graph.c>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/**
16+
* @file
17+
*/
18+
19+
#ifndef RMW_MICROROS__MEMORY_ERROR_HANDLING_H_
20+
#define RMW_MICROROS__MEMORY_ERROR_HANDLING_H_
21+
22+
// #include <rmw/rmw.h>
23+
// #include <rmw/ret_types.h>
24+
// #include <rmw/init_options.h>
25+
// #include <rmw_microxrcedds_c/config.h>
26+
// #include <ucdr/microcdr.h>
27+
28+
#if defined(__cplusplus)
29+
extern "C"
30+
{
31+
#endif // if defined(__cplusplus)
32+
33+
typedef void (* rmw_uros_memory_error_handling)(
34+
char * identifier,
35+
uint8_t * buffer,
36+
size_t size);
37+
38+
/** \addtogroup rmw micro-ROS RMW API
39+
* @{
40+
*/
41+
42+
/**
43+
* \brief Sets the callback functions for handling error in static memory handling
44+
*
45+
* \param[in] memory_error_cb publisher where continous serialization is being configured
46+
*/
47+
void rmw_uros_set_memory_error_handling_callback(
48+
rmw_uros_memory_error_handling memory_error_cb);
49+
50+
/** @}*/
51+
52+
#if defined(__cplusplus)
53+
}
54+
#endif // if defined(__cplusplus)
55+
56+
#endif // RMW_MICROROS__MEMORY_ERROR_HANDLING_H_

rmw_microxrcedds_c/src/callbacks.c

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

1515
#include <rmw_microros_internal/callbacks.h>
16-
1716
#include <rmw/error_handling.h>
17+
#include <rmw_microros/memory_error_handling.h>
18+
19+
extern rmw_uros_memory_error_handling memory_error_callback;
1820

1921
void on_status(
2022
struct uxrSession * session,
@@ -77,6 +79,9 @@ void on_topic(
7779
if (!memory_node) {
7880
RMW_SET_ERROR_MSG("Not available static buffer memory node");
7981
UXR_UNLOCK(&static_buffer_memory.mutex);
82+
if(NULL != memory_error_callback) {
83+
memory_error_callback("Not available static_buffer_memory for subscription", ub->iterator, length);
84+
}
8085
return;
8186
}
8287

@@ -129,6 +134,9 @@ void on_request(
129134
if (!memory_node) {
130135
RMW_SET_ERROR_MSG("Not available static buffer memory node");
131136
UXR_UNLOCK(&static_buffer_memory.mutex);
137+
if(NULL != memory_error_callback) {
138+
memory_error_callback("Not available static_buffer_memory for request", ub->iterator, length);
139+
}
132140
return;
133141
}
134142

@@ -183,6 +191,9 @@ void on_reply(
183191
if (!memory_node) {
184192
RMW_SET_ERROR_MSG("Not available static buffer memory node");
185193
UXR_UNLOCK(&static_buffer_memory.mutex);
194+
if(NULL != memory_error_callback) {
195+
memory_error_callback("Not available static_buffer_memory for reply", ub->iterator, length);
196+
}
186197
return;
187198
}
188199

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <rmw/rmw.h>
16+
#include <rmw_microros/memory_error_handling.h>
17+
18+
rmw_uros_memory_error_handling memory_error_callback = NULL;
19+
20+
void rmw_uros_set_memory_error_handling_callback(
21+
rmw_uros_memory_error_handling memory_error_cb)
22+
{
23+
memory_error_callback = memory_error_cb;
24+
}

0 commit comments

Comments
 (0)