Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions fastdds_python_examples/HelloWorldExample/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ message(STATUS "Configuring python wrapper for types in HelloWorld...")

project(HelloWorld)

find_package(fastcdr REQUIRED CONFIG)
find_package(fastrtps REQUIRED CONFIG)
find_package(fastcdr REQUIRED)
find_package(fastrtps REQUIRED)


set(${PROJECT_NAME}_FILES
HelloWorld.cxx
Expand Down Expand Up @@ -85,10 +86,11 @@ SWIG_LINK_LIBRARIES(${${PROJECT_NAME}_MODULE}
)

# Find the installation path
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}' ) )"
OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))"
OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

get_filename_component (_ABS_PYTHON_MODULE_PATH ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE)
file (RELATIVE_PATH _REL_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH})
SET (PYTHON_MODULE_PATH
Expand All @@ -104,3 +106,4 @@ install(TARGETS ${PROJECT_NAME}
install(TARGETS ${${PROJECT_NAME}_MODULE} DESTINATION ${PYTHON_MODULE_PATH})
get_property(support_files TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_SUPPORT_FILES)
install(FILES ${support_files} DESTINATION ${PYTHON_MODULE_PATH})

4 changes: 2 additions & 2 deletions fastdds_python_examples/HelloWorldExample/HelloWorld.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ using namespace eprosima::fastcdr::exception;

HelloWorld::HelloWorld()
{
// m_index com.eprosima.idl.parser.typecode.PrimitiveTypeCode@74a10858
// m_index com.eprosima.idl.parser.typecode.PrimitiveTypeCode@1dfe2924
m_index = 0;
// m_message com.eprosima.idl.parser.typecode.StringTypeCode@23fe1d71
// m_message com.eprosima.idl.parser.typecode.StringTypeCode@6ebc05a6
m_message ="";

}
Expand Down
22 changes: 11 additions & 11 deletions fastdds_python_examples/HelloWorldExample/HelloWorldPubSubTypes.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,21 @@ bool HelloWorldPubSubType::deserialize(
SerializedPayload_t* payload,
void* data)
{
//Convert DATA to pointer of your type
HelloWorld* p_type = static_cast<HelloWorld*>(data);
try
{
//Convert DATA to pointer of your type
HelloWorld* p_type = static_cast<HelloWorld*>(data);

// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload->data), payload->length);
// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload->data), payload->length);

// Object that deserializes the data.
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR);
// Object that deserializes the data.
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR);

// Deserialize encapsulation.
deser.read_encapsulation();
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
// Deserialize encapsulation.
deser.read_encapsulation();
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;

try
{
// Deserialize the object.
p_type->deserialize(deser);
}
Expand Down