Skip to content

Commit

Permalink
Release v2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pablogs9 authored Jun 28, 2022
2 parents 2195d43 + c2b41c7 commit 6f4edd2
Show file tree
Hide file tree
Showing 13 changed files with 373 additions and 76 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ option(UCLIENT_PROFILE_MATCHING "Enable QoS matching support." OFF)
set(UCLIENT_SHARED_MEMORY_MAX_ENTITIES 4 CACHE STRING "Max number of entities involved in shared memory.")
set(UCLIENT_SHARED_MEMORY_STATIC_MEM_SIZE 10 CACHE STRING "Max number data buffers stored in shared memory")

option(UCLIENT_HARD_LIVELINESS_CHECK "Enable hard liveliness check." OFF)
set(UCLIENT_HARD_LIVELINESS_CHECK_TIMEOUT 10000 CACHE STRING "Set the hard liveliness check interval in milliseconds.")

# Off-standard features and tweaks
option(UCLIENT_TWEAK_XRCE_WRITE_LIMIT "This feature uses a tweak to allow XRCE WRITE DATA submessages grater than 64 kB." ON)

Expand All @@ -87,7 +90,7 @@ list(APPEND _deps "microcdr\;${_microcdr_version}")
###############################################################################
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
if(NOT UCLIENT_SUPERBUILD)
project(microxrcedds_client VERSION "2.1.1" LANGUAGES C)
project(microxrcedds_client VERSION "2.2.0" LANGUAGES C)
else()
project(uclient_superbuild NONE)
include(${PROJECT_SOURCE_DIR}/cmake/SuperBuild.cmake)
Expand Down Expand Up @@ -181,6 +184,8 @@ if(UCLIENT_PROFILE_TCP)
list(APPEND _transport_src src/c/profile/transport/ip/tcp/tcp_transport.c)
if(UCLIENT_PLATFORM_POSIX)
list(APPEND _transport_src src/c/profile/transport/ip/tcp/tcp_transport_posix.c)
elseif(UCLIENT_PLATFORM_POSIX_NOPOLL)
list(APPEND _transport_src src/c/profile/transport/ip/tcp/tcp_transport_posix_nopoll.c)
elseif(UCLIENT_PLATFORM_WINDOWS)
list(APPEND _transport_src src/c/profile/transport/ip/tcp/tcp_transport_windows.c)
elseif(UCLIENT_PLATFORM_FREERTOS_PLUS_TCP)
Expand Down
3 changes: 3 additions & 0 deletions cmake/SuperBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ if(NOT microcdr_FOUND)
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_SYSROOT:PATH=${CMAKE_SYSROOT}
-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCONFIG_BIG_ENDIANNESS=${UCLIENT_BIG_ENDIANNESS}
-DUCDR_PIC=${UCLIENT_PIC}
Expand Down
4 changes: 0 additions & 4 deletions cmake/common/check_configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,11 @@ function(set_common_compile_options target)
target_compile_options(${target} PRIVATE -Wall
-Wextra
-Wshadow
$<$<COMPILE_LANGUAGE:CXX>:-Wnon-virtual-dtor>
-pedantic
-Wcast-align
-Wunused
$<$<COMPILE_LANGUAGE:CXX>:-Woverloaded-virtual>
-Wconversion
$<$<CXX_COMPILER_ID:GNU>:-Wlogical-op>
$<$<AND:$<CXX_COMPILER_ID:GNU>,$<COMPILE_LANGUAGE:CXX>>:-Wuseless-cast>
$<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast>
$<$<OR:$<AND:$<CXX_COMPILER_ID:GNU>,$<NOT:$<VERSION_LESS:$<CXX_COMPILER_VERSION>,6.0.0>>>,$<AND:$<C_COMPILER_ID:GNU>,$<NOT:$<VERSION_LESS:$<C_COMPILER_VERSION>,6.0.0>>>>:-Wnull-dereference>
$<$<OR:$<AND:$<CXX_COMPILER_ID:GNU>,$<NOT:$<VERSION_LESS:$<CXX_COMPILER_VERSION>,7.0.0>>>,$<AND:$<C_COMPILER_ID:GNU>,$<NOT:$<VERSION_LESS:$<C_COMPILER_VERSION>,7.0.0>>>>:-Wduplicated-branches>
$<$<OR:$<AND:$<CXX_COMPILER_ID:GNU>,$<NOT:$<VERSION_LESS:$<CXX_COMPILER_VERSION>,6.0.0>>>,$<AND:$<C_COMPILER_ID:GNU>,$<NOT:$<VERSION_LESS:$<C_COMPILER_VERSION>,6.0.0>>>>:-Wduplicated-cond>
Expand Down
13 changes: 13 additions & 0 deletions include/uxr/client/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,18 @@

#cmakedefine UCLIENT_TWEAK_XRCE_WRITE_LIMIT

#cmakedefine UCLIENT_HARD_LIVELINESS_CHECK

#ifdef UCLIENT_HARD_LIVELINESS_CHECK
#define UXR_CONFIG_HARD_LIVELINESS_CHECK_TIMEOUT_STR "@UCLIENT_HARD_LIVELINESS_CHECK_TIMEOUT@"
#endif


// Version checks
#if UXR_CLIENT_VERSION_MAJOR >= 3
#error UCLIENT_HARD_LIVELINESS_CHECK shall be included in session API
#error MTU must be included in CREATE_CLIENT_Payload properties
#error Reorder ObjectInfo https://github.com/eProsima/Micro-XRCE-DDS/issues/137
#endif

#endif // _UXR_CLIENT_CONFIG_H_
18 changes: 18 additions & 0 deletions include/uxr/client/core/type/xrce_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ extern "C"
#endif // ifdef __cplusplus

#include <uxr/client/defines.h>
#include <uxr/client/config.h>

#include <ucdr/microcdr.h>
#include <stdint.h>
Expand All @@ -40,7 +41,24 @@ extern "C"
#define UXR_SAMPLE_DELTA_SEQUENCE_MAX 8
#define UXR_PACKED_SAMPLES_SEQUENCE_MAX 8
#define UXR_TRANSPORT_LOCATOR_SEQUENCE_MAX 4

#ifdef UCLIENT_PROFILE_SHARED_MEMORY
#define PROFILE_SHARED_MEMORY_SEQ_COUNT 1
#else
#define PROFILE_SHARED_MEMORY_SEQ_COUNT 0
#endif // ifdef UCLIENT_PROFILE_SHARED_MEMORY

#ifdef UCLIENT_HARD_LIVELINESS_CHECK
#define HARD_LIVELINESS_CHECK_SEQ_COUNT 1
#else
#define HARD_LIVELINESS_CHECK_SEQ_COUNT 0
#endif // ifdef UCLIENT_HARD_LIVELINESS_CHECK

#if (PROFILE_SHARED_MEMORY_SEQ_COUNT + HARD_LIVELINESS_CHECK_SEQ_COUNT) == 0
#define UXR_PROPERTY_SEQUENCE_MAX 1
#else
#define UXR_PROPERTY_SEQUENCE_MAX PROFILE_SHARED_MEMORY_SEQ_COUNT + HARD_LIVELINESS_CHECK_SEQ_COUNT
#endif // if (PROFILE_SHARED_MEMORY_SEQ_COUNT + HARD_LIVELINESS_CHECK_SEQ_COUNT) == 0

typedef struct Time_t
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2018 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.

#ifndef UXR_CLIENT_PROFILE_TRANSPORT_IP_TCP_TCPTRANSPORTPOSIXNOPOLL_H_
#define UXR_CLIENT_PROFILE_TRANSPORT_IP_TCP_TCPTRANSPORTPOSIXNOPOLL_H_

#ifdef __cplusplus
extern "C"
{
#endif // ifdef __cplusplus

typedef struct uxrTCPPlatform
{
int fd;
} uxrTCPPlatform;

#ifdef __cplusplus
}
#endif // ifdef __cplusplus

#endif // UXR_CLIENT_PROFILE_TRANSPORT_IP_TCP_TCPTRANSPORTPOSIXNOPOLL_H_
4 changes: 3 additions & 1 deletion include/uxr/client/transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
#endif //UCLIENT_PROFILE_UDP

#ifdef UCLIENT_PROFILE_TCP
#if defined(UCLIENT_PLATFORM_POSIX)
#if defined(UCLIENT_PLATFORM_POSIX_NOPOLL)
#include <uxr/client/profile/transport/ip/tcp/tcp_transport_posix_nopoll.h>
#elif defined(UCLIENT_PLATFORM_POSIX)
#include <uxr/client/profile/transport/ip/tcp/tcp_transport_posix.h>
#elif defined(UCLIENT_PLATFORM_WINDOWS)
#include <uxr/client/profile/transport/ip/tcp/tcp_transport_windows.h>
Expand Down
2 changes: 1 addition & 1 deletion include/uxr/client/util/ping.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extern "C"
#define UXR_PING_BUF 16 // 4 (HEADER SIZE) + 4 (SUBHEADER_SIZE) + 8 (GET_Info payload)

#define GET_INFO_MSG_SIZE 8
#define GET_INFO_REQUEST_ID 9
#define GET_INFO_REQUEST_PING_ID 10

struct uxrSession;

Expand Down
155 changes: 97 additions & 58 deletions src/c/core/session/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,23 @@
#include "../../profile/shared_memory/shared_memory_internal.h"

#ifdef UCLIENT_PROFILE_SHARED_MEMORY
#define CREATE_SESSION_PROPERTIES_MAX_SIZE 21
#define CREATE_SESSION_MAX_MSG_SIZE (MAX_HEADER_SIZE + SUBHEADER_SIZE + CREATE_CLIENT_PAYLOAD_SIZE + \
CREATE_SESSION_PROPERTIES_MAX_SIZE)
#define PROFILE_SHARED_MEMORY_ADD_SIZE 21
#else
#define CREATE_SESSION_MAX_MSG_SIZE (MAX_HEADER_SIZE + SUBHEADER_SIZE + CREATE_CLIENT_PAYLOAD_SIZE)
#define PROFILE_SHARED_MEMORY_ADD_SIZE 0
#endif /* ifdef UCLIENT_PROFILE_SHARED_MEMORY */

#ifdef UCLIENT_HARD_LIVELINESS_CHECK
#define HARD_LIVELINESS_CHECK_ADD_SIZE 26
#else
#define HARD_LIVELINESS_CHECK_ADD_SIZE 0
#endif /* ifdef UCLIENT_HARD_LIVELINESS_CHECK */

#define CREATE_SESSION_PROPERTIES_MAX_SIZE PROFILE_SHARED_MEMORY_ADD_SIZE + HARD_LIVELINESS_CHECK_ADD_SIZE


#define CREATE_SESSION_MAX_MSG_SIZE (MAX_HEADER_SIZE + SUBHEADER_SIZE + CREATE_CLIENT_PAYLOAD_SIZE + \
CREATE_SESSION_PROPERTIES_MAX_SIZE)

#define DELETE_SESSION_MAX_MSG_SIZE (MAX_HEADER_SIZE + SUBHEADER_SIZE + DELETE_CLIENT_PAYLOAD_SIZE)
#define HEARTBEAT_MAX_MSG_SIZE (MAX_HEADER_SIZE + SUBHEADER_SIZE + HEARTBEAT_PAYLOAD_SIZE)
#define ACKNACK_MAX_MSG_SIZE (MAX_HEADER_SIZE + SUBHEADER_SIZE + ACKNACK_PAYLOAD_SIZE)
Expand Down Expand Up @@ -102,6 +112,12 @@ static void read_submessage_acknack(
static void read_submessage_timestamp_reply(
uxrSession* session,
ucdrBuffer* submessage);
static void read_submessage_get_info(
uxrSession* session,
ucdrBuffer* submessage);
void read_submessage_info(
uxrSession* session,
ucdrBuffer* submessage);
#ifdef PERFORMANCE_TESTING
static void read_submessage_performance(
uxrSession* session,
Expand All @@ -125,9 +141,6 @@ static bool run_session_until_sync(
uxrSession* session,
int timeout);

pong_status_t uxr_acknack_pong(
ucdrBuffer* buffer);

//==================================================================
// PUBLIC
//==================================================================
Expand Down Expand Up @@ -626,52 +639,6 @@ void uxr_flash_output_streams(
//==================================================================
// PRIVATE
//==================================================================
pong_status_t uxr_acknack_pong(
ucdrBuffer* buffer)
{
bool success = false;
bool ret = false;
bool active_session = false;

if (ucdr_buffer_remaining(buffer) > SUBHEADER_SIZE)
{
uint8_t id = 0;
uint8_t flags = 0;
uint16_t length = 0;
uxr_deserialize_submessage_header(buffer, &id, &flags, &length);
success = ucdr_buffer_remaining(buffer) >= length;

if (success && id == SUBMESSAGE_ID_INFO)
{
INFO_Payload info_payload;

success &= uxr_deserialize_BaseObjectReply(buffer, &info_payload.base);
active_session = info_payload.base.result.implementation_status;

success &= ucdr_deserialize_bool(buffer, &info_payload.object_info.optional_config);

if (info_payload.object_info.optional_config)
{
success &= uxr_deserialize_ObjectVariant(buffer, &info_payload.object_info.config);
}

success &= ucdr_deserialize_bool(buffer, &info_payload.object_info.optional_activity);
if (info_payload.object_info.optional_activity)
{
success &= ucdr_deserialize_uint8_t(buffer, &info_payload.object_info.activity.kind);
if (success && DDS_XRCE_OBJK_AGENT == info_payload.object_info.activity.kind)
{
success &= ucdr_deserialize_int16_t(buffer,
&info_payload.object_info.activity._.agent.availability);
ret = success && (info_payload.object_info.activity._.agent.availability > 0);
}
}
}
}

return ret ? (active_session ? PONG_IN_SESSION_STATUS : PONG_NO_SESSION_STATUS) : NO_PONG_STATUS;
}

bool uxr_run_session_until_pong(
uxrSession* session,
int timeout_ms)
Expand Down Expand Up @@ -781,7 +748,15 @@ bool wait_session_status(
for (size_t i = 0; i < attempts && session->info.last_requested_status == UXR_STATUS_NONE; ++i)
{
send_message(session, buffer, length);
listen_message(session, UXR_CONFIG_MIN_SESSION_CONNECTION_INTERVAL);

int64_t start_timestamp = uxr_millis();
int remaining_time = UXR_CONFIG_MIN_SESSION_CONNECTION_INTERVAL;

do
{
listen_message(session, remaining_time);
remaining_time = UXR_CONFIG_MIN_SESSION_CONNECTION_INTERVAL - (int)(uxr_millis() - start_timestamp);
} while (remaining_time > 0 && session->info.last_requested_status == UXR_STATUS_NONE);
}

return session->info.last_requested_status != UXR_STATUS_NONE;
Expand Down Expand Up @@ -877,10 +852,6 @@ void read_message(
uxrStreamId id = uxr_stream_id_from_raw(stream_id_raw, UXR_INPUT_STREAM);
read_stream(session, ub, id, seq_num);
}
else
{
session->on_pong_flag = uxr_acknack_pong(ub);
}
}

void read_stream(
Expand Down Expand Up @@ -989,6 +960,14 @@ void read_submessage(
read_submessage_timestamp_reply(session, submessage);
break;

case SUBMESSAGE_ID_GET_INFO:
read_submessage_get_info(session, submessage);
break;

case SUBMESSAGE_ID_INFO:
read_submessage_info(session, submessage);
break;

#ifdef PERFORMANCE_TESTING
case SUBMESSAGE_ID_PERFORMANCE:
read_submessage_performance(session, submessage, length);
Expand Down Expand Up @@ -1095,6 +1074,66 @@ void read_submessage_timestamp_reply(
process_timestamp_reply(session, &timestamp_reply);
}

void read_submessage_get_info(
uxrSession* session,
ucdrBuffer* submessage)
{
GET_INFO_Payload get_info_payload = {
0
};
INFO_Payload info_payload = {
0
};

uxr_deserialize_GET_INFO_Payload(submessage, &get_info_payload);

info_payload.base.related_request.request_id = get_info_payload.base.request_id;

uint8_t buffer[12];
ucdrBuffer ub;
ucdr_init_buffer_origin_offset(&ub, buffer, sizeof(buffer), 0u, uxr_session_header_offset(&session->info));

uxr_serialize_INFO_Payload(&ub, &info_payload);
uxr_stamp_session_header(&session->info, 0, 0, ub.init);

send_message(session, buffer, ucdr_buffer_length(&ub));
}

void read_submessage_info(
uxrSession* session,
ucdrBuffer* submessage)
{
INFO_Payload info_payload;

bool success = true;

success &= uxr_deserialize_BaseObjectReply(submessage, &info_payload.base);
bool active_session = info_payload.base.result.implementation_status;

success &= ucdr_deserialize_bool(submessage, &info_payload.object_info.optional_config);

if (info_payload.object_info.optional_config)
{
success &= uxr_deserialize_ObjectVariant(submessage, &info_payload.object_info.config);
}

success &= ucdr_deserialize_bool(submessage, &info_payload.object_info.optional_activity);
if (info_payload.object_info.optional_activity)
{
success &= ucdr_deserialize_uint8_t(submessage, &info_payload.object_info.activity.kind);
if (success && DDS_XRCE_OBJK_AGENT == info_payload.object_info.activity.kind)
{
success &= ucdr_deserialize_int16_t(submessage,
&info_payload.object_info.activity._.agent.availability);
session->on_pong_flag = (success && (info_payload.object_info.activity._.agent.availability > 0)) ?
(active_session ?
PONG_IN_SESSION_STATUS :
PONG_NO_SESSION_STATUS) :
NO_PONG_STATUS;
}
}
}

#ifdef PERFORMANCE_TESTING
void read_submessage_performance(
uxrSession* session,
Expand Down
Loading

0 comments on commit 6f4edd2

Please sign in to comment.