-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose raw CDR stream for publish and subscribe #186
Merged
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4847d18
publish raw function
Karsten1987 40dbb47
take raw
Karsten1987 30e512c
linters
Karsten1987 9644f70
add rmw_serialize functions
Karsten1987 fbf2e8e
rmw_fastrtps_cpp/src/rmw_serialize memory leak when creating typesupport
Karsten1987 48b6f79
linters
Karsten1987 0151654
comparison size_t with unsigned int
Karsten1987 0a215eb
remove asserts
Karsten1987 13bdb7c
refactor take code
Karsten1987 1ee0447
use rcutls macro
Karsten1987 f882044
changes for rebase
Karsten1987 80866cf
warn unused
Karsten1987 a1e0261
fix typo
Karsten1987 a0f4776
raw->serialized
Karsten1987 ea5adda
use size_t (#206)
wjwwood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "fastcdr/FastBuffer.h" | ||
|
||
#include "rmw/error_handling.h" | ||
#include "rmw/serialized_message.h" | ||
#include "rmw/rmw.h" | ||
|
||
#include "./type_support_common.hpp" | ||
#include "./ros_message_serialization.hpp" | ||
|
||
extern "C" | ||
{ | ||
rmw_ret_t | ||
rmw_serialize( | ||
const void * ros_message, | ||
const rosidl_message_type_support_t * type_support, | ||
rmw_serialized_message_t * serialized_message) | ||
{ | ||
const rosidl_message_type_support_t * ts = get_message_typesupport_handle( | ||
type_support, rosidl_typesupport_introspection_c__identifier); | ||
if (!ts) { | ||
ts = get_message_typesupport_handle( | ||
type_support, rosidl_typesupport_introspection_cpp::typesupport_identifier); | ||
if (!ts) { | ||
RMW_SET_ERROR_MSG("type support not from this implementation"); | ||
return RMW_RET_ERROR; | ||
} | ||
} | ||
|
||
auto tss = _create_message_type_support(ts->data, ts->typesupport_identifier); | ||
eprosima::fastcdr::FastBuffer buffer; | ||
eprosima::fastcdr::Cdr ser( | ||
buffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); | ||
|
||
auto ret = _serialize_ros_message(ros_message, ser, tss, ts->typesupport_identifier); | ||
auto data_length = static_cast<unsigned int>(ser.getSerializedDataLength()); | ||
if (serialized_message->buffer_capacity < data_length) { | ||
if (rmw_serialized_message_resize(serialized_message, data_length) != RMW_RET_OK) { | ||
RMW_SET_ERROR_MSG("unable to dynamically resize serialized message"); | ||
return RMW_RET_ERROR; | ||
} | ||
} | ||
memcpy(serialized_message->buffer, ser.getBufferPointer(), data_length); | ||
serialized_message->buffer_length = data_length; | ||
serialized_message->buffer_capacity = data_length; | ||
_delete_typesupport(tss, ts->typesupport_identifier); | ||
return ret == true ? RMW_RET_OK : RMW_RET_ERROR; | ||
} | ||
|
||
rmw_ret_t | ||
rmw_deserialize( | ||
const rmw_serialized_message_t * serialized_message, | ||
const rosidl_message_type_support_t * type_support, | ||
void * ros_message) | ||
{ | ||
const rosidl_message_type_support_t * ts = get_message_typesupport_handle( | ||
type_support, rosidl_typesupport_introspection_c__identifier); | ||
if (!ts) { | ||
ts = get_message_typesupport_handle( | ||
type_support, rosidl_typesupport_introspection_cpp::typesupport_identifier); | ||
if (!ts) { | ||
RMW_SET_ERROR_MSG("type support not from this implementation"); | ||
return RMW_RET_ERROR; | ||
} | ||
} | ||
|
||
auto tss = _create_message_type_support(ts->data, ts->typesupport_identifier); | ||
eprosima::fastcdr::FastBuffer buffer( | ||
serialized_message->buffer, serialized_message->buffer_length); | ||
eprosima::fastcdr::Cdr deser(buffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, | ||
eprosima::fastcdr::Cdr::DDS_CDR); | ||
|
||
auto ret = _deserialize_ros_message(deser, ros_message, tss, ts->typesupport_identifier); | ||
_delete_typesupport(tss, ts->typesupport_identifier); | ||
return ret == true ? RMW_RET_OK : RMW_RET_ERROR; | ||
} | ||
} // extern "C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get a compiler error here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it supposed to beEdit: oops, I didn't read the comment.buffer->resize()
?