Skip to content

Commit e83c6b7

Browse files
committed
Initial
Signed-off-by: Pablo Garrido <pablogs9@gmail.com> Uncrustify Signed-off-by: Pablo Garrido <pablogs9@gmail.com> Update Signed-off-by: Pablo Garrido <pablogs9@gmail.com> Uncrus Signed-off-by: Pablo Garrido <pablogs9@gmail.com>
1 parent 1660762 commit e83c6b7

4 files changed

Lines changed: 92 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: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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 <ucdr/microcdr.h>
23+
24+
#if defined(__cplusplus)
25+
extern "C"
26+
{
27+
#endif // if defined(__cplusplus)
28+
29+
typedef void (* rmw_uros_memory_error_handling)(
30+
char * identifier,
31+
ucdrBuffer * ucdr,
32+
size_t size);
33+
34+
/** \addtogroup rmw micro-ROS RMW API
35+
* @{
36+
*/
37+
38+
/**
39+
* \brief Sets the callback functions for handling error in static memory handling
40+
*
41+
* \param[in] memory_error_cb publisher where continous serialization is being configured
42+
*/
43+
void rmw_uros_set_memory_error_handling_callback(
44+
rmw_uros_memory_error_handling memory_error_cb);
45+
46+
/** @}*/
47+
48+
#if defined(__cplusplus)
49+
}
50+
#endif // if defined(__cplusplus)
51+
52+
#endif // RMW_MICROROS__MEMORY_ERROR_HANDLING_H_

rmw_microxrcedds_c/src/callbacks.c

Lines changed: 15 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,10 @@ 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(
84+
"Not available static_buffer_memory for subscription", ub, length);
85+
}
8086
return;
8187
}
8288

@@ -129,6 +135,10 @@ void on_request(
129135
if (!memory_node) {
130136
RMW_SET_ERROR_MSG("Not available static buffer memory node");
131137
UXR_UNLOCK(&static_buffer_memory.mutex);
138+
if (NULL != memory_error_callback) {
139+
memory_error_callback(
140+
"Not available static_buffer_memory for request", ub, length);
141+
}
132142
return;
133143
}
134144

@@ -183,6 +193,10 @@ void on_reply(
183193
if (!memory_node) {
184194
RMW_SET_ERROR_MSG("Not available static buffer memory node");
185195
UXR_UNLOCK(&static_buffer_memory.mutex);
196+
if (NULL != memory_error_callback) {
197+
memory_error_callback(
198+
"Not available static_buffer_memory for reply", ub, length);
199+
}
186200
return;
187201
}
188202

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)