diff --git a/CMakeLists.txt b/CMakeLists.txt index d3c2e46f6..9ac38fe6b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,7 @@ set(UCLIENT_MAX_INPUT_RELIABLE_STREAMS 1 CACHE STRING "Set the maximum number of set(UCLIENT_MAX_SESSION_CONNECTION_ATTEMPTS 10 CACHE STRING "Set the number of connection attemps.") set(UCLIENT_MIN_SESSION_CONNECTION_INTERVAL 1000 CACHE STRING "Set the connection interval in milliseconds.") set(UCLIENT_MIN_HEARTBEAT_TIME_INTERVAL 100 CACHE STRING "Set the time interval between heartbeats in milliseconds.") +set(UCLIENT_RELIABLE_RESENT_TIME 100 CACHE STRING "Set the time for reliable stream resend in milliseconds.") set(UCLIENT_UDP_TRANSPORT_MTU 512 CACHE STRING "Set the UDP transport MTU.") set(UCLIENT_TCP_TRANSPORT_MTU 512 CACHE STRING "Set the TCP transport MTU.") set(UCLIENT_SERIAL_TRANSPORT_MTU 512 CACHE STRING "Set the Serial transport MTU.") diff --git a/include/uxr/client/config.h.in b/include/uxr/client/config.h.in index 7b00cd2ce..416fcdaea 100644 --- a/include/uxr/client/config.h.in +++ b/include/uxr/client/config.h.in @@ -46,6 +46,7 @@ #define UXR_CONFIG_MAX_SESSION_CONNECTION_ATTEMPTS @UCLIENT_MAX_SESSION_CONNECTION_ATTEMPTS@ #define UXR_CONFIG_MIN_SESSION_CONNECTION_INTERVAL @UCLIENT_MIN_SESSION_CONNECTION_INTERVAL@ #define UXR_CONFIG_MIN_HEARTBEAT_TIME_INTERVAL @UCLIENT_MIN_HEARTBEAT_TIME_INTERVAL@ +#define UXR_CONFIG_RELIABLE_RESENT_TIME @UCLIENT_RELIABLE_RESENT_TIME@ #ifdef UCLIENT_PROFILE_UDP #define UXR_CONFIG_UDP_TRANSPORT_MTU @UCLIENT_UDP_TRANSPORT_MTU@ diff --git a/src/c/core/session/stream/output_reliable_stream.c b/src/c/core/session/stream/output_reliable_stream.c index 93ca6e25a..a49235966 100644 --- a/src/c/core/session/stream/output_reliable_stream.c +++ b/src/c/core/session/stream/output_reliable_stream.c @@ -9,6 +9,7 @@ #include "./common_reliable_stream_internal.h" #include "../submessage_internal.h" #include +#include #define MIN_HEARTBEAT_TIME_INTERVAL ((int64_t) UXR_CONFIG_MIN_HEARTBEAT_TIME_INTERVAL) // ms @@ -64,6 +65,7 @@ bool uxr_prepare_reliable_buffer_to_write( uint16_t available_block_size = (uint16_t)(buffer_capacity - (uint16_t)(stream->offset + SUBHEADER_SIZE)); size_t remaining_blocks = get_available_free_slots(stream); + static int64_t reliable_ackend_ts = 0x0; // Aligment required for inserting an XRCE subheader buffer_size += ucdr_alignment(buffer_size, 4); @@ -164,6 +166,17 @@ bool uxr_prepare_reliable_buffer_to_write( } } + if (available_to_write == false) { + if (reliable_ackend_ts == 0x0) { + reliable_ackend_ts = uxr_millis() + UXR_CONFIG_RELIABLE_RESENT_TIME; + } else if (reliable_ackend_ts <= uxr_millis()) { + stream->last_sent = uxr_seq_num_sub(stream->last_sent, 1); + reliable_ackend_ts = uxr_millis() + UXR_CONFIG_RELIABLE_RESENT_TIME; + } + } else { + reliable_ackend_ts = 0x0; + } + return available_to_write; } diff --git a/test/shared_memory/CMakeLists.txt b/test/shared_memory/CMakeLists.txt index 25cb81793..8f059c62c 100644 --- a/test/shared_memory/CMakeLists.txt +++ b/test/shared_memory/CMakeLists.txt @@ -78,3 +78,5 @@ set_target_properties(sharedmem_test PROPERTIES CXX_STANDARD_REQUIRED YES ) + +include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/../../src) \ No newline at end of file diff --git a/test/shared_memory/SharedMemory.cpp b/test/shared_memory/SharedMemory.cpp index f1f86d3f6..69158bb53 100644 --- a/test/shared_memory/SharedMemory.cpp +++ b/test/shared_memory/SharedMemory.cpp @@ -1,3 +1,8 @@ +extern "C" +{ +#include +} + #include #include diff --git a/test/unitary/session/streams/OutputReliableStream.cpp b/test/unitary/session/streams/OutputReliableStream.cpp index da05eab47..f087de036 100644 --- a/test/unitary/session/streams/OutputReliableStream.cpp +++ b/test/unitary/session/streams/OutputReliableStream.cpp @@ -8,6 +8,7 @@ extern "C" #include #include #include +#include } #define BUFFER_SIZE size_t(128)