Skip to content

Commit 2b282df

Browse files
authored
Update type support with Fast DDS-Gen v2.1.1 (#10)
Signed-off-by: Eduardo Ponz <eduardoponz@eprosima.com>
1 parent 3b88247 commit 2b282df

3 files changed

Lines changed: 22 additions & 19 deletions

File tree

fastdds_python_examples/HelloWorldExample/CMakeLists.txt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ message(STATUS "Configuring python wrapper for types in HelloWorld...")
2525

2626
project(HelloWorld)
2727

28-
find_package(fastcdr REQUIRED CONFIG)
29-
find_package(fastrtps REQUIRED CONFIG)
28+
find_package(fastcdr REQUIRED)
29+
find_package(fastrtps REQUIRED)
30+
3031

3132
set(${PROJECT_NAME}_FILES
3233
HelloWorld.cxx
@@ -85,10 +86,11 @@ SWIG_LINK_LIBRARIES(${${PROJECT_NAME}_MODULE}
8586
)
8687

8788
# Find the installation path
88-
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}' ) )"
89-
OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH
90-
OUTPUT_STRIP_TRAILING_WHITESPACE
91-
)
89+
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))"
90+
OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH
91+
OUTPUT_STRIP_TRAILING_WHITESPACE
92+
)
93+
9294
get_filename_component (_ABS_PYTHON_MODULE_PATH ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE)
9395
file (RELATIVE_PATH _REL_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH})
9496
SET (PYTHON_MODULE_PATH
@@ -104,3 +106,4 @@ install(TARGETS ${PROJECT_NAME}
104106
install(TARGETS ${${PROJECT_NAME}_MODULE} DESTINATION ${PYTHON_MODULE_PATH})
105107
get_property(support_files TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_SUPPORT_FILES)
106108
install(FILES ${support_files} DESTINATION ${PYTHON_MODULE_PATH})
109+

fastdds_python_examples/HelloWorldExample/HelloWorld.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ using namespace eprosima::fastcdr::exception;
3636

3737
HelloWorld::HelloWorld()
3838
{
39-
// m_index com.eprosima.idl.parser.typecode.PrimitiveTypeCode@74a10858
39+
// m_index com.eprosima.idl.parser.typecode.PrimitiveTypeCode@1dfe2924
4040
m_index = 0;
41-
// m_message com.eprosima.idl.parser.typecode.StringTypeCode@23fe1d71
41+
// m_message com.eprosima.idl.parser.typecode.StringTypeCode@6ebc05a6
4242
m_message ="";
4343

4444
}

fastdds_python_examples/HelloWorldExample/HelloWorldPubSubTypes.cxx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,21 @@ bool HelloWorldPubSubType::deserialize(
8282
SerializedPayload_t* payload,
8383
void* data)
8484
{
85-
//Convert DATA to pointer of your type
86-
HelloWorld* p_type = static_cast<HelloWorld*>(data);
85+
try
86+
{
87+
//Convert DATA to pointer of your type
88+
HelloWorld* p_type = static_cast<HelloWorld*>(data);
8789

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

91-
// Object that deserializes the data.
92-
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR);
93+
// Object that deserializes the data.
94+
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR);
9395

94-
// Deserialize encapsulation.
95-
deser.read_encapsulation();
96-
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
96+
// Deserialize encapsulation.
97+
deser.read_encapsulation();
98+
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
9799

98-
try
99-
{
100100
// Deserialize the object.
101101
p_type->deserialize(deser);
102102
}

0 commit comments

Comments
 (0)