Pre-release 1.1.0 (#92)

* Refs #5500. Fix SuperBuild update and BUILD_SHARED_LIBS flag.

* Refs #5500. Improve SuperBuild package lookup.

* Refs #5500. Remane SuperBuild variables.

* Refs #5500. Minor changes in CMakeLists.txt file.

* Refs #5500. Update SuperBuild download command.

* Refs #5500. Modify config.h file generation.

* Refs #5511. Remove unnecessary export attribute.

* Refs 5511. Change HINTS by PATH in in CMake's find_package function.

* Refs #5511. Add BUILD_SHARED_LIBS CMake option.

* Refs #5511. Remove unnecessary files.

* Refs #5511. Update microcdr.

* Refs #5511. Remove integration tests from CMakeLists.txt

* Refs #5511. Modify project version and update microcdr.

* Refs #5511. Add nuttx_toolchain template.

* Refs #5511. Fix toolchain configuration file generation.

* Refs #5511. Remove unnecessary SuperBuild flags.

* Refs #5581. Update microcdr release/1.1.0.

* Refs #5581. Bump microcdr version 1.0.1 -> 1.1.0.

* Update microcdr thirdparty.

* Refs #5581. Update microcdr.
This commit is contained in:
Julián Bermúdez Ortega 2019-06-10 10:10:09 +02:00 committed by Borja Outerelo
parent fd2e6929e5
commit 27e5809e26
30 changed files with 83 additions and 1251 deletions

View File

@ -17,14 +17,26 @@
################################################################################
cmake_minimum_required(VERSION 3.5.0 FATAL_ERROR)
option(SUPERBUILD "Active super build" ON)
###############################################################################
# Build options
###############################################################################
option(UCLIENT_SUPERBUILD "Enable superbuild compilation." ON)
option(UCLIENT_BUILD_TESTS "Build tests" OFF)
option(UCLIENT_BUILD_EXAMPLES "Build examples" OFF)
option(UCLIENT_VERBOSE_SERIALIZATION "Build with serialization verbosity" OFF)
option(UCLIENT_VERBOSE_MESSAGE "Build with message verbosity" OFF)
option(BUILD_SHARED_LIBS "Control shared/static library building." OFF)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
option(UCLIENT_MEMORY_TESTS "Build memory tests" OFF)
option(UCLIENT_PERFORMANCE_TESTS "Build performance tests" OFF)
endif()
if(SUPERBUILD)
project(superbuild NONE)
include(cmake/SuperBuild.cmake)
if(UCLIENT_SUPERBUILD)
project(uclient_superbuild NONE)
include(${PROJECT_SOURCE_DIR}/cmake/SuperBuild.cmake)
return()
else()
project(microxrcedds_client VERSION "1.0.1" LANGUAGES C)
project(microxrcedds_client VERSION "1.1.0" LANGUAGES C)
endif()
# Set CMAKE_BUILD_TYPE to Release by default.
@ -37,15 +49,18 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
endif()
###############################################################################
# Build options
# Config
###############################################################################
option(UCLIENT_BUILD_TESTS "Build tests" OFF)
option(UCLIENT_BUILD_EXAMPLES "Build examples" OFF)
option(UCLIENT_VERBOSE_SERIALIZATION "Build with serialization verbosity" OFF)
option(UCLIENT_VERBOSE_MESSAGE "Build with message verbosity" OFF)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
option(UCLIENT_MEMORY_TESTS "Build memory tests" OFF)
option(UCLIENT_PERFORMANCE_TESTS "Build performance tests" OFF)
# Install path
include(GNUInstallDirs)
set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Installation directory for binaries")
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Installation directory for C headers")
set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
set(DATA_INSTALL_DIR ${CMAKE_INSTALL_DATADIR} CACHE PATH "Installation directory for data")
if(WIN32)
set(LICENSE_INSTALL_DIR . CACHE PATH "Installation directory for licenses")
else()
set(LICENSE_INSTALL_DIR ${DATA_INSTALL_DIR}/${PROJECT_NAME} CACHE PATH "Installation directory for licenses")
endif()
###############################################################################
@ -73,10 +88,7 @@ endif()
###############################################################################
# Load external eProsima projects.
###############################################################################
find_package(microcdr 1.0.1 EXACT REQUIRED
HINTS
${PROJECT_BINARY_DIR}/temp_install
)
find_package(microcdr 1.1.0 EXACT REQUIRED PATHS ${PROJECT_BINARY_DIR}/temp_install)
###############################################################################
# Sources
@ -216,26 +228,6 @@ target_include_directories(${PROJECT_NAME}
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/c>
)
###############################################################################
# Config
###############################################################################
# Install path
include(GNUInstallDirs)
set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Installation directory for binaries")
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Installation directory for C headers")
set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
set(DATA_INSTALL_DIR ${CMAKE_INSTALL_DATADIR} CACHE PATH "Installation directory for data")
if(WIN32)
set(LICENSE_INSTALL_DIR . CACHE PATH "Installation directory for licenses")
else()
set(LICENSE_INSTALL_DIR ${DATA_INSTALL_DIR}/${PROJECT_NAME} CACHE PATH "Installation directory for licenses")
endif()
# Generate config.h
configure_file(${PROJECT_SOURCE_DIR}/include/uxr/client/config.h.in
${PROJECT_BINARY_DIR}/include/uxr/client/config.h
)
###############################################################################
# Compile setting
###############################################################################
@ -279,14 +271,9 @@ if(UCLIENT_BUILD_TESTS)
enable_testing()
include(CTest)
if(NOT ((MSVC OR MSVC_IDE) AND EPROSIMA_INSTALLER))
add_subdirectory(test/unitary)
add_subdirectory(test/integration/interaction)
if(NOT WIN32)
add_subdirectory(test/transport/serial_comm)
add_subdirectory(test/integration/cross_serialization)
endif()
add_subdirectory(test/unitary)
if(PLATFORM_NAME_LINUX)
add_subdirectory(test/transport/serial_comm)
endif()
endif()
@ -322,6 +309,11 @@ install(
PATTERN "*.h"
)
# Generate config.h
configure_file(${PROJECT_SOURCE_DIR}/include/uxr/client/config.h.in
${PROJECT_BINARY_DIR}/include/uxr/client/config.h
)
# Install config.h
install(
FILES

View File

@ -17,11 +17,12 @@ include(ExternalProject)
unset(_deps)
# Micro CDR.
find_package(microcdr "1.0.1" EXACT QUIET)
unset(microcdr_DIR CACHE)
find_package(microcdr "1.1.0" EXACT QUIET)
if(NOT microcdr_FOUND)
ExternalProject_Add(ucdr
DOWNLOAD_COMMAND
git submodule update --init ${PROJECT_SOURCE_DIR}/thirdparty/microcdr/
cd ${PROJECT_SOURCE_DIR} && git submodule update --init thirdparty/microcdr/
PREFIX
${PROJECT_BINARY_DIR}/ucdr
SOURCE_DIR
@ -29,28 +30,23 @@ if(NOT microcdr_FOUND)
INSTALL_DIR
${PROJECT_BINARY_DIR}/temp_install
CMAKE_ARGS
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
"-DARCH_CPU_FLAGS:STRING="${ARCH_CPU_FLAGS}""
"-DARCH_OPT_FLAGS:STRING="${ARCH_OPT_FLAGS}""
"-DCMAKE_SYSROOT:PATH=${CMAKE_SYSROOT}"
"-DCROSSDEV:STRING=${CROSSDEV}"
"-DCHECK_ENDIANNESS:BOOL=${CHECK_ENDIANNESS}"
-DCMAKE_SYSROOT:PATH=${CMAKE_SYSROOT}
-DCHECK_ENDIANNESS:BOOL=${CHECK_ENDIANNESS}
)
LIST(APPEND _deps ucdr)
list(APPEND _deps ucdr)
endif()
# Client project.
ExternalProject_Add(uclient
UPDATE_COMMAND
""
SOURCE_DIR
${PROJECT_SOURCE_DIR}
BINARY_DIR
${CMAKE_CURRENT_BINARY_DIR}
CMAKE_ARGS
-DSUPERBUILD=OFF
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
CMAKE_CACHE_ARGS
-DUCLIENT_SUPERBUILD:BOOL=OFF
INSTALL_COMMAND
""
DEPENDS

View File

@ -20,7 +20,7 @@ extern "C"
{
#endif
#include <uxr/client/dll.h>
#include <uxr/client/visibility.h>
#include <stdint.h>
#define UXR_INVALID_ID 0x00

View File

@ -20,7 +20,7 @@ extern "C"
{
#endif
#include <uxr/client/dll.h>
#include <uxr/client/visibility.h>
#include <stdint.h>
/**

View File

@ -21,7 +21,7 @@ extern "C"
#endif
#include <uxr/client/config.h>
#include <uxr/client/dll.h>
#include <uxr/client/visibility.h>
#include <stdint.h>
#include <stdbool.h>

View File

@ -23,7 +23,7 @@ extern "C"
#include <uxr/client/core/communication/communication.h>
#include <uxr/client/profile/transport/serial/serial_protocol.h>
#include <uxr/client/config.h>
#include <uxr/client/dll.h>
#include <uxr/client/visibility.h>
struct uxrSerialPlatform;

View File

@ -20,7 +20,7 @@ extern "C"
{
#endif
#include <uxr/client/dll.h>
#include <uxr/client/visibility.h>
#include <stddef.h>
#include <stdint.h>

View File

@ -22,7 +22,7 @@ extern "C"
#include <uxr/client/core/communication/communication.h>
#include <uxr/client/config.h>
#include <uxr/client/dll.h>
#include <uxr/client/visibility.h>
typedef enum uxrTCPInputBufferState
{

View File

@ -22,7 +22,7 @@ extern "C"
#include <uxr/client/core/communication/communication.h>
#include <uxr/client/config.h>
#include <uxr/client/dll.h>
#include <uxr/client/visibility.h>
struct uxrUDPPlatform;

View File

@ -20,7 +20,7 @@ extern "C"
{
#endif
#include <uxr/client/dll.h>
#include <uxr/client/visibility.h>
#include <stdint.h>
UXRDLLAPI int64_t uxr_millis(void);

View File

@ -13,8 +13,8 @@
// limitations under the License.
#ifndef _UXR_CLIENT_DLL_H_
#define _UXR_CLIENT_DLL_H_
#ifndef _UXR_CLIENT_VISIBILITY_H_
#define _UXR_CLIENT_VISIBILITY_H_
#if defined(_WIN32)
#if defined(microxrcedds_client_SHARED)
@ -30,4 +30,4 @@
#define UXRDLLAPI
#endif // _WIN32
#endif // _UXR_CLIENT_DLL_H_
#endif // _UXR_CLIENT_VISIBILITY_H_

View File

@ -20,7 +20,7 @@ extern "C"
{
#endif
#include <uxr/client/dll.h>
#include <uxr/client/visibility.h>
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>

View File

@ -20,7 +20,7 @@ extern "C"
{
#endif
#include <uxr/client/dll.h>
#include <uxr/client/visibility.h>
#include <uxr/client/config.h>
#include <stdint.h>

View File

@ -20,10 +20,10 @@ extern "C"
{
#endif
#include <uxr/client/dll.h>
#include <uxr/client/visibility.h>
#include <stdint.h>
UXRDLLAPI static inline int64_t uxr_convert_to_nanos(int32_t sec, uint32_t nsec)
static inline int64_t uxr_convert_to_nanos(int32_t sec, uint32_t nsec)
{
return ((int64_t)sec * 1000000000) + nsec;
}

View File

@ -1,40 +0,0 @@
###############################################################################
#
# Copyright 2017 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.
#
###############################################################################
project(cross-serialization-intest-client CXX)
set(SRCS ClientSerialization.cpp)
add_library(${PROJECT_NAME} STATIC ${SRCS})
set_common_compile_options(${PROJECT_NAME})
if(MSVC OR MSVC_IDE)
target_compile_options(${PROJECT_NAME} PRIVATE /wd4996)
endif()
get_target_property(CLIENT_INCLUDES microxrcedds_client INCLUDE_DIRECTORIES)
include_directories("${CLIENT_INCLUDES}") #Used to include private includes
target_link_libraries(${PROJECT_NAME} microxrcedds_client)
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
)
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
)

View File

@ -1,315 +0,0 @@
#include "ClientSerialization.hpp"
#include <core/serialization/xrce_protocol_internal.h>
#include <ucdr/microcdr.h>
#include <cstring>
#define BUFFER_LENGTH 1024
std::vector<uint8_t> ClientSerialization::create_client_payload()
{
//change in a future by client_payload_sizeof function and remove resize
std::vector<uint8_t> buffer(BUFFER_LENGTH, 0x00);
ucdrBuffer ub;
ucdr_init_buffer(&ub, &buffer.front(), uint32_t(buffer.capacity()));
CREATE_CLIENT_Payload payload;
payload.client_representation.xrce_cookie = XrceCookie{0x89, 0xAB, 0xCD, 0xEF};
payload.client_representation.xrce_version = XrceVersion{0x01, 0x23};
payload.client_representation.xrce_vendor_id = XrceVendorId{0x45, 0x67};
payload.client_representation.client_key = ClientKey{0x89, 0xAB, 0xCD, 0xEF};
payload.client_representation.session_id = 0x01;
payload.client_representation.optional_properties = 0x00;
payload.client_representation.mtu = 0x2345;
uxr_serialize_CREATE_CLIENT_Payload(&ub, &payload);
buffer.resize(std::size_t(ub.iterator - ub.init));
return buffer;
}
std::vector<uint8_t> ClientSerialization::create_payload()
{
std::vector<uint8_t> buffer(BUFFER_LENGTH, 0x00);
ucdrBuffer ub;
ucdr_init_buffer(&ub, &buffer.front(), uint32_t(buffer.capacity()));
CREATE_Payload payload;
payload.base.request_id = RequestId{0x01, 0x23};
payload.base.object_id = ObjectId{0x45, 0x67};
payload.object_representation.kind = OBJK_PARTICIPANT;
payload.object_representation._.participant.base.representation.format = REPRESENTATION_BY_REFERENCE;
payload.object_representation._.participant.domain_id = int16_t(0x09AB);
payload.object_representation._.participant.base.representation._.object_reference = const_cast<char*>("ABCDE");
uxr_serialize_CREATE_Payload(&ub, &payload);
buffer.resize(std::size_t(ub.iterator - ub.init));
return buffer;
}
std::vector<uint8_t> ClientSerialization::get_info_payload()
{
std::vector<uint8_t> buffer(BUFFER_LENGTH, 0x00);
ucdrBuffer ub;
ucdr_init_buffer(&ub, &buffer.front(), uint32_t(buffer.capacity()));
GET_INFO_Payload payload;
payload.base.request_id = RequestId{0x01, 0x23};
payload.base.object_id = ObjectId{0x45, 0x67};
payload.info_mask = 0x89ABCDEF;
uxr_serialize_GET_INFO_Payload(&ub, &payload);
buffer.resize(std::size_t(ub.iterator - ub.init));
return buffer;
}
std::vector<uint8_t> ClientSerialization::delete_payload()
{
std::vector<uint8_t> buffer(BUFFER_LENGTH, 0x00);
ucdrBuffer ub;
ucdr_init_buffer(&ub, &buffer.front(), uint32_t(buffer.capacity()));
DELETE_Payload payload;
payload.base.request_id = RequestId{0x01, 0x23};
payload.base.object_id = ObjectId{0x45, 0x67};
uxr_serialize_DELETE_Payload(&ub, &payload);
buffer.resize(std::size_t(ub.iterator - ub.init));
return buffer;
}
std::vector<uint8_t> ClientSerialization::status_agent_payload()
{
std::vector<uint8_t> buffer(BUFFER_LENGTH, 0x00);
ucdrBuffer ub;
ucdr_init_buffer(&ub, &buffer.front(), uint32_t(buffer.capacity()));
STATUS_AGENT_Payload payload;
payload.result.status = {0x01};
payload.result.implementation_status = {0x23};
payload.agent_info.xrce_cookie = XrceCookie{0x89, 0xAB, 0xCD, 0xEF};
payload.agent_info.xrce_version = XrceVersion{0x01, 0x23};
payload.agent_info.xrce_vendor_id = XrceVendorId{0x45, 0x67};
payload.agent_info.optional_properties = 0x00;
uxr_serialize_STATUS_AGENT_Payload(&ub, &payload);
buffer.resize(std::size_t(ub.iterator - ub.init));
return buffer;
}
std::vector<uint8_t> ClientSerialization::status_payload()
{
std::vector<uint8_t> buffer(BUFFER_LENGTH, 0x00);
ucdrBuffer ub;
ucdr_init_buffer(&ub, &buffer.front(), uint32_t(buffer.capacity()));
STATUS_Payload payload;
payload.base.related_request.request_id = RequestId{0x01, 0x23};
payload.base.related_request.object_id = ObjectId{0x45, 0x67};
payload.base.result.implementation_status = 0x89;
payload.base.result.status = 0xAB;
uxr_serialize_STATUS_Payload(&ub, &payload);
buffer.resize(std::size_t(ub.iterator - ub.init));
return buffer;
}
std::vector<uint8_t> ClientSerialization::info_payload()
{
std::vector<uint8_t> buffer(BUFFER_LENGTH, 0x00);
ucdrBuffer ub;
ucdr_init_buffer(&ub, &buffer.front(), uint32_t(buffer.capacity()));
INFO_Payload payload;
payload.base.related_request.request_id = RequestId{0x01, 0x23};
payload.base.related_request.object_id = ObjectId{0x45, 0x67};
payload.base.result.implementation_status = 0x89;
payload.base.result.status = 0xAB;
payload.object_info.optional_activity = 0x01;
payload.object_info.optional_config = 0x01;
payload.object_info.config.kind = OBJK_AGENT;
payload.object_info.config._.agent.optional_properties = 0x00;
payload.object_info.config._.agent.xrce_cookie = XrceCookie{0x89, 0xAB, 0xCD, 0xEF};
payload.object_info.config._.agent.xrce_version = XrceVersion{0x01, 0x23};
payload.object_info.config._.agent.xrce_vendor_id = XrceVendorId{0x45, 0x67};
payload.object_info.activity.kind = OBJK_AGENT;
payload.object_info.activity._.agent.availibility = 1;
payload.object_info.activity._.agent.address_seq.size = 0x01;
payload.object_info.activity._.agent.address_seq.data[0].format = ADDRESS_FORMAT_MEDIUM;
payload.object_info.activity._.agent.address_seq.data[0]._.medium_locator.locator_port = 0x0123;
payload.object_info.activity._.agent.address_seq.data[0]._.medium_locator.address[0] = 0x01;
payload.object_info.activity._.agent.address_seq.data[0]._.medium_locator.address[1] = 0x23;
payload.object_info.activity._.agent.address_seq.data[0]._.medium_locator.address[2] = 0x45;
payload.object_info.activity._.agent.address_seq.data[0]._.medium_locator.address[3] = 0x67;
uxr_serialize_INFO_Payload(&ub, &payload);
buffer.resize(std::size_t(ub.iterator - ub.init));
return buffer;
}
std::vector<uint8_t> ClientSerialization::read_data_payload()
{
std::vector<uint8_t> buffer(BUFFER_LENGTH, 0x00);
ucdrBuffer ub;
ucdr_init_buffer(&ub, &buffer.front(), uint32_t(buffer.capacity()));
READ_DATA_Payload payload;
payload.base.request_id = RequestId{0x01, 0x23};
payload.base.object_id = ObjectId{0x45, 0x67};
payload.read_specification.preferred_stream_id = 0x80;
payload.read_specification.data_format = 0x89;
payload.read_specification.optional_content_filter_expression = 0x01;
payload.read_specification.optional_delivery_control = 0x01;
payload.read_specification.delivery_control.max_bytes_per_seconds = 0xABCD;
payload.read_specification.delivery_control.max_elapsed_time = 0x2345;
payload.read_specification.delivery_control.max_samples = 0xABCD;
payload.read_specification.delivery_control.min_pace_period = 0xEF01;
payload.read_specification.content_filter_expression = const_cast<char*>("ABCDE");
uxr_serialize_READ_DATA_Payload(&ub, &payload);
buffer.resize(std::size_t(ub.iterator - ub.init));
return buffer;
}
std::vector<uint8_t> ClientSerialization::write_data_payload_data()
{
std::vector<uint8_t> buffer(BUFFER_LENGTH, 0x00);
ucdrBuffer ub;
ucdr_init_buffer(&ub, &buffer.front(), uint32_t(buffer.capacity()));
WRITE_DATA_Payload_Data payload;
payload.base.request_id = RequestId{0x01, 0x23};
payload.base.object_id = ObjectId{0x45, 0x67};
uxr_serialize_WRITE_DATA_Payload_Data(&ub, &payload);
ucdr_serialize_array_char(&ub, "BYTES", 5);
buffer.resize(std::size_t(ub.iterator - ub.init));
return buffer;
}
std::vector<uint8_t> ClientSerialization::write_data_payload_sample()
{
//TODO
return std::vector<uint8_t>();
}
std::vector<uint8_t> ClientSerialization::write_data_payload_data_seq()
{
//TODO
return std::vector<uint8_t>();
}
std::vector<uint8_t> ClientSerialization::write_data_payload_sample_seq()
{
//TODO
return std::vector<uint8_t>();
}
std::vector<uint8_t> ClientSerialization::write_data_payload_packed_samples()
{
//TODO
return std::vector<uint8_t>();
}
std::vector<uint8_t> ClientSerialization::data_payload_data()
{
std::vector<uint8_t> buffer(BUFFER_LENGTH, 0x00);
ucdrBuffer ub;
ucdr_init_buffer(&ub, &buffer.front(), uint32_t(buffer.capacity()));
BaseObjectRequest base;
base.request_id = RequestId{0x01, 0x23};
base.object_id = ObjectId{0x45, 0x67};
uxr_serialize_BaseObjectRequest(&ub, &base);
ucdr_serialize_array_char(&ub, "BYTES", 5);
buffer.resize(std::size_t(ub.iterator - ub.init));
return buffer;
}
std::vector<uint8_t> ClientSerialization::data_payload_sample()
{
//TODO
return std::vector<uint8_t>();
}
std::vector<uint8_t> ClientSerialization::data_payload_data_seq()
{
//TODO
return std::vector<uint8_t>();
}
std::vector<uint8_t> ClientSerialization::data_payload_sample_seq()
{
//TODO
return std::vector<uint8_t>();
}
std::vector<uint8_t> ClientSerialization::data_payload_packed_samples()
{
//TODO
return std::vector<uint8_t>();
}
std::vector<uint8_t> ClientSerialization::acknack_payload()
{
std::vector<uint8_t> buffer(BUFFER_LENGTH, 0x00);
ucdrBuffer ub;
ucdr_init_buffer(&ub, &buffer.front(), uint32_t(buffer.capacity()));
ACKNACK_Payload payload;
payload.first_unacked_seq_num = uint16_t(0x0123);
payload.nack_bitmap[0] = uint8_t(0x45);
payload.nack_bitmap[1] = uint8_t(0x67);
payload.stream_id = uint8_t(0x89);
uxr_serialize_ACKNACK_Payload(&ub, &payload);
buffer.resize(std::size_t(ub.iterator - ub.init));
return buffer;
}
std::vector<uint8_t> ClientSerialization::heartbeat_payload()
{
std::vector<uint8_t> buffer(BUFFER_LENGTH, 0x00);
ucdrBuffer ub;
ucdr_init_buffer(&ub, &buffer.front(), uint32_t(buffer.capacity()));
HEARTBEAT_Payload payload;
payload.first_unacked_seq_nr = uint16_t(0x0123);
payload.last_unacked_seq_nr = uint16_t(0x4567);
payload.stream_id = uint8_t(0x89);
uxr_serialize_HEARTBEAT_Payload(&ub, &payload);
buffer.resize(std::size_t(ub.iterator - ub.init));
return buffer;
}

View File

@ -1,31 +0,0 @@
#ifndef IN_TEST_CLIENT_CROSS_SERIALIZATION_HPP
#define IN_TEST_CLIENT_CROSS_SERIALIZATION_HPP
#include <cstdint>
#include <vector>
struct ClientSerialization
{
static std::vector<uint8_t> create_client_payload();
static std::vector<uint8_t> create_payload();
static std::vector<uint8_t> get_info_payload();
static std::vector<uint8_t> delete_payload();
static std::vector<uint8_t> status_agent_payload();
static std::vector<uint8_t> status_payload();
static std::vector<uint8_t> info_payload();
static std::vector<uint8_t> read_data_payload();
static std::vector<uint8_t> write_data_payload_data();
static std::vector<uint8_t> write_data_payload_sample();
static std::vector<uint8_t> write_data_payload_data_seq();
static std::vector<uint8_t> write_data_payload_sample_seq();
static std::vector<uint8_t> write_data_payload_packed_samples();
static std::vector<uint8_t> data_payload_data();
static std::vector<uint8_t> data_payload_sample();
static std::vector<uint8_t> data_payload_data_seq();
static std::vector<uint8_t> data_payload_sample_seq();
static std::vector<uint8_t> data_payload_packed_samples();
static std::vector<uint8_t> acknack_payload();
static std::vector<uint8_t> heartbeat_payload();
};
#endif //IN_TEST_CLIENT_CROSS_SERIALIZATION_HPP

View File

@ -1,53 +0,0 @@
// 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.
/*!
* @file BigHelloWorld.c
* This source file contains the definition of the described types in the IDL file.
*
* This file was generated by the tool gen.
*/
#include "BigHelloWorld.h"
#include <ucdr/microcdr.h>
#include <string.h>
bool BigHelloWorld_serialize_topic(ucdrBuffer* writer, const BigHelloWorld* topic)
{
(void) ucdr_serialize_uint32_t(writer, topic->index);
(void) ucdr_serialize_string(writer, topic->message);
return !writer->error;
}
bool BigHelloWorld_deserialize_topic(ucdrBuffer* reader, BigHelloWorld* topic)
{
(void) ucdr_deserialize_uint32_t(reader, &topic->index);
(void) ucdr_deserialize_string(reader, topic->message, 4096);
return !reader->error;
}
uint32_t BigHelloWorld_size_of_topic(const BigHelloWorld* topic, uint32_t size)
{
uint32_t previousSize = size;
size += (uint32_t)(ucdr_alignment(size, 4) + 4);
size += (uint32_t)(ucdr_alignment(size, 4) + 4 + strlen(topic->message) + 1);
return size - previousSize;
}

View File

@ -1,55 +0,0 @@
// 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.
/*!
* @file BigHelloWorld.h
* This header file contains the declaration of the described types in the IDL file.
*
* This file was generated by the tool gen.
*/
#ifndef _BigHelloWorld_H_
#define _BigHelloWorld_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
#include <stdbool.h>
/*!
* @brief This struct represents the structure BigHelloWorld defined by the user in the IDL file.
* @ingroup BIGHELLOWORLD
*/
typedef struct BigHelloWorld
{
uint32_t index;
char message[4096];
} BigHelloWorld;
struct ucdrBuffer;
bool BigHelloWorld_serialize_topic(struct ucdrBuffer* writer, const BigHelloWorld* topic);
bool BigHelloWorld_deserialize_topic(struct ucdrBuffer* reader, BigHelloWorld* topic);
uint32_t BigHelloWorld_size_of_topic(const BigHelloWorld* topic, uint32_t size);
#ifdef __cplusplus
}
#endif
#endif // _BigHelloWorld_H_

View File

@ -1,5 +0,0 @@
struct HelloWorld
{
unsigned long index;
string<4096> message;
};

View File

@ -1,50 +0,0 @@
###############################################################################
#
# Copyright 2017 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.
#
###############################################################################
if(NOT PROFILE_UDP_TRANSPORT OR
NOT PROFILE_TCP_TRANSPORT OR
NOT PROFILE_SERIAL_TRANSPORT)
message(WARNING "Can not compile test: The ROFILE_UDP_TRANSPORT, PROFILE_TCP_PROFILE and PROFILE_SERIAL_TRANSPORT must be enabled.")
else()
project(interaction-intest-client CXX)
set(SRCS
Discovery.cpp
Client.cpp
Gateway.cpp
BigHelloWorld.c
)
add_library(${PROJECT_NAME} STATIC ${SRCS})
set_common_compile_options(${PROJECT_NAME})
if(MSVC OR MSVC_IDE)
target_compile_options(${PROJECT_NAME} PRIVATE /wd4996)
endif()
target_include_directories(${PROJECT_NAME} PRIVATE ${GTEST_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} microxrcedds_client ${GTEST_BOTH_LIBRARIES})
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
)
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
)
endif()

View File

@ -1,66 +0,0 @@
#include "Client.hpp"
const char* Client::participant_xml_ = "<dds>"
"<participant>"
"<rtps>"
"<name>default_xrce_participant</name>"
"</rtps>"
"</participant>"
"</dds>";
const char* Client::topic_xml_ = "<dds>"
"<topic>"
"<name>BigHelloWorldTopic</name>"
"<dataType>BigHelloWorld</dataType>"
"</topic>"
"</dds>";
const char* Client::publisher_xml_ = "";
const char* Client::datawriter_xml_ = "<dds>"
"<data_writer>"
"<historyMemoryPolicy>PREALLOCATED_WITH_REALLOC</historyMemoryPolicy>"
"<topic>"
"<kind>NO_KEY</kind>"
"<name>BigHelloWorldTopic</name>"
"<dataType>BigHelloWorld</dataType>"
"<historyQos>"
"<kind>KEEP_LAST</kind>"
"<depth>10</depth>"
"</historyQos>"
"</topic>"
"<qos>"
"<durability>"
"<kind>TRANSIENT_LOCAL</kind>"
"</durability>"
"</qos>"
"</data_writer>"
"</dds>";
const char* Client::subscriber_xml_ = "";
const char* Client::datareader_xml_ = "<dds>"
"<data_reader>"
"<historyMemoryPolicy>PREALLOCATED_WITH_REALLOC</historyMemoryPolicy>"
"<topic>"
"<kind>NO_KEY</kind>"
"<name>BigHelloWorldTopic</name>"
"<dataType>BigHelloWorld</dataType>"
"<historyQos>"
"<kind>KEEP_LAST</kind>"
"<depth>10</depth>"
"</historyQos>"
"</topic>"
"<qos>"
"<durability>"
"<kind>TRANSIENT_LOCAL</kind>"
"</durability>"
"</qos>"
"</data_reader>"
"</dds>";
uint32_t Client::next_client_key_ = 0;

View File

@ -1,360 +0,0 @@
#ifndef IN_TEST_CLIENT_HPP
#define IN_TEST_CLIENT_HPP
#include "BigHelloWorld.h"
#include "Gateway.hpp"
#include <uxr/client/client.h>
#include <ucdr/microcdr.h>
#include <gtest/gtest.h>
#include <iostream>
#include <thread>
#define UDP_TRANSPORT 1
#define TCP_TRANSPORT 2
inline bool operator == (const uxrObjectId& obj1, const uxrObjectId& obj2)
{
return obj1.id == obj2.id
&& obj1.type == obj2.type;
}
inline bool operator == (const uxrStreamId& s1, const uxrStreamId& s2)
{
return s1.raw == s2.raw
&& s1.index == s2.index
&& s1.type == s2.type
&& s1.direction == s2.direction;
}
class Client
{
public:
Client(float lost, uint16_t history)
: gateway_(lost)
, client_key_(++next_client_key_)
, history_(history)
{
}
virtual ~Client()
{}
void create_entities_xml(uint8_t id, uint8_t stream_id_raw, uint8_t expected_status, uint8_t flags)
{
uxrStreamId output_stream_id = uxr_stream_id_from_raw(stream_id_raw, UXR_OUTPUT_STREAM);
uint16_t request_id; uint8_t status;
uxrObjectId participant_id = uxr_object_id(id, UXR_PARTICIPANT_ID);
request_id = uxr_buffer_create_participant_xml(&session_, output_stream_id, participant_id, 0, participant_xml_, flags);
ASSERT_NE(UXR_INVALID_REQUEST_ID, request_id);
uxr_run_session_until_all_status(&session_, 3000, &request_id, &status, 1);
ASSERT_EQ(expected_status, status);
uxrObjectId topic_id = uxr_object_id(id, UXR_TOPIC_ID);
request_id = uxr_buffer_create_topic_xml(&session_, output_stream_id, topic_id, participant_id, topic_xml_, flags);
ASSERT_NE(UXR_INVALID_REQUEST_ID, request_id);
uxr_run_session_until_all_status(&session_, 3000, &request_id, &status, 1);
ASSERT_EQ(expected_status, status);
uxrObjectId publisher_id = uxr_object_id(id, UXR_PUBLISHER_ID);
request_id = uxr_buffer_create_publisher_xml(&session_, output_stream_id, publisher_id, participant_id, publisher_xml_, flags);
ASSERT_NE(UXR_INVALID_REQUEST_ID, request_id);
uxr_run_session_until_all_status(&session_, 3000, &request_id, &status, 1);
ASSERT_EQ(expected_status, status);
uxrObjectId datawriter_id = uxr_object_id(id, UXR_DATAWRITER_ID);
request_id = uxr_buffer_create_datawriter_xml(&session_, output_stream_id, datawriter_id, publisher_id, datawriter_xml_, flags);
ASSERT_NE(UXR_INVALID_REQUEST_ID, request_id);
uxr_run_session_until_all_status(&session_, 3000, &request_id, &status, 1);
ASSERT_EQ(expected_status, status);
uxrObjectId subscriber_id = uxr_object_id(id, UXR_SUBSCRIBER_ID);
request_id = uxr_buffer_create_subscriber_xml(&session_, output_stream_id, subscriber_id, participant_id, subscriber_xml_, flags);
ASSERT_NE(UXR_INVALID_REQUEST_ID, request_id);
uxr_run_session_until_all_status(&session_, 3000, &request_id, &status, 1);
ASSERT_EQ(expected_status, status);
uxrObjectId datareader_id = uxr_object_id(id, UXR_DATAREADER_ID);
request_id = uxr_buffer_create_datareader_xml(&session_, output_stream_id, datareader_id, subscriber_id, datareader_xml_, flags);
ASSERT_NE(UXR_INVALID_REQUEST_ID, request_id);
uxr_run_session_until_all_status(&session_, 3000, &request_id, &status, 1);
ASSERT_EQ(expected_status, status);
}
void create_entities_ref(uint8_t id, uint8_t stream_id_raw, uint8_t expected_status, uint8_t flags)
{
uxrStreamId output_stream_id = uxr_stream_id_from_raw(stream_id_raw, UXR_OUTPUT_STREAM);
uint16_t request_id; uint8_t status;
uxrObjectId participant_id = uxr_object_id(id, UXR_PARTICIPANT_ID);
request_id = uxr_buffer_create_participant_ref(&session_, output_stream_id, participant_id, 0, "default_xrce_participant", flags);
ASSERT_NE(UXR_INVALID_REQUEST_ID, request_id);
uxr_run_session_until_all_status(&session_, 3000, &request_id, &status, 1);
ASSERT_EQ(expected_status, status);
ASSERT_EQ(expected_status, last_status_);
ASSERT_EQ(participant_id, last_status_object_id_);
ASSERT_EQ(request_id, last_status_request_id_);
uxrObjectId topic_id = uxr_object_id(id, UXR_TOPIC_ID);
request_id = uxr_buffer_create_topic_ref(&session_, output_stream_id, topic_id, participant_id, "bighelloworld_topic", flags);
ASSERT_NE(UXR_INVALID_REQUEST_ID, request_id);
uxr_run_session_until_all_status(&session_, 3000, &request_id, &status, 1);
ASSERT_EQ(expected_status, status);
ASSERT_EQ(expected_status, last_status_);
ASSERT_EQ(topic_id, last_status_object_id_);
ASSERT_EQ(request_id, last_status_request_id_);
uxrObjectId publisher_id = uxr_object_id(id, UXR_PUBLISHER_ID);
request_id = uxr_buffer_create_publisher_xml(&session_, output_stream_id, publisher_id, participant_id, "", flags);
ASSERT_NE(UXR_INVALID_REQUEST_ID, request_id);
uxr_run_session_until_all_status(&session_, 3000, &request_id, &status, 1);
ASSERT_EQ(expected_status, status);
ASSERT_EQ(expected_status, last_status_);
ASSERT_EQ(publisher_id, last_status_object_id_);
ASSERT_EQ(request_id, last_status_request_id_);
uxrObjectId datawriter_id = uxr_object_id(id, UXR_DATAWRITER_ID);
request_id = uxr_buffer_create_datawriter_ref(&session_, output_stream_id, datawriter_id, publisher_id, "bighelloworld_data_writer", flags);
ASSERT_NE(UXR_INVALID_REQUEST_ID, request_id);
uxr_run_session_until_all_status(&session_, 3000, &request_id, &status, 1);
ASSERT_EQ(expected_status, status);
ASSERT_EQ(expected_status, last_status_);
ASSERT_EQ(datawriter_id, last_status_object_id_);
ASSERT_EQ(request_id, last_status_request_id_);
uxrObjectId subscriber_id = uxr_object_id(id, UXR_SUBSCRIBER_ID);
request_id = uxr_buffer_create_subscriber_xml(&session_, output_stream_id, subscriber_id, participant_id, "", flags);
ASSERT_NE(UXR_INVALID_REQUEST_ID, request_id);
uxr_run_session_until_all_status(&session_, 3000, &request_id, &status, 1);
ASSERT_EQ(expected_status, status);
ASSERT_EQ(expected_status, last_status_);
ASSERT_EQ(subscriber_id, last_status_object_id_);
ASSERT_EQ(request_id, last_status_request_id_);
uxrObjectId datareader_id = uxr_object_id(id, UXR_DATAREADER_ID);
request_id = uxr_buffer_create_datareader_ref(&session_, output_stream_id, datareader_id, subscriber_id, "bighelloworld_data_reader", flags);
ASSERT_NE(UXR_INVALID_REQUEST_ID, request_id);
uxr_run_session_until_all_status(&session_, 3000, &request_id, &status, 1);
ASSERT_EQ(expected_status, status);
ASSERT_EQ(expected_status, last_status_);
ASSERT_EQ(datareader_id, last_status_object_id_);
ASSERT_EQ(request_id, last_status_request_id_);
}
void publish(uint8_t id, uint8_t stream_id_raw, size_t number, const std::string& message)
{
//Used only for waiting the RTPS subscriber matching
(void) uxr_run_session_time(&session_, 500);
uxrStreamId output_stream_id = uxr_stream_id_from_raw(stream_id_raw, UXR_OUTPUT_STREAM);
uxrObjectId datawriter_id = uxr_object_id(id, UXR_DATAWRITER_ID);
for(size_t i = 0; i < number; ++i)
{
BigHelloWorld topic;
topic.index = static_cast<uint32_t>(i);
strcpy(topic.message, message.c_str());
ucdrBuffer ub;
uint32_t topic_size = BigHelloWorld_size_of_topic(&topic, 0);
bool prepared = uxr_prepare_output_stream(&session_, output_stream_id, datawriter_id, &ub, topic_size);
ASSERT_TRUE(prepared);
bool written = BigHelloWorld_serialize_topic(&ub, &topic);
ASSERT_TRUE(written);
ASSERT_FALSE(ub.error);
bool sent = uxr_run_session_until_confirm_delivery(&session_, 3000);
ASSERT_TRUE(sent);
std::cout << "topic sent: " << i << std::endl;
}
}
void subscribe(uint8_t id, uint8_t stream_id_raw, size_t number, const std::string& message)
{
expected_message_ = message;
expected_topic_index_ = 0;
last_topic_stream_id_ = uxr_stream_id_from_raw(0, UXR_OUTPUT_STREAM);
last_topic_object_id_ = uxr_object_id(255, 15);
uxrStreamId output_stream_id = uxr_stream_id(0, UXR_RELIABLE_STREAM, UXR_OUTPUT_STREAM);
uxrStreamId input_stream_id = uxr_stream_id_from_raw(stream_id_raw, UXR_INPUT_STREAM);
uxrObjectId datareader_id = uxr_object_id(id, UXR_DATAREADER_ID);
uxrDeliveryControl delivery_control = {};
delivery_control.max_samples = UXR_MAX_SAMPLES_UNLIMITED;
uint16_t request_id = uxr_buffer_request_data(&session_, output_stream_id, datareader_id, input_stream_id, &delivery_control);
ASSERT_NE(UXR_INVALID_REQUEST_ID, request_id);
while(expected_topic_index_ < number)
{
uint8_t status;
bool received_ok = uxr_run_session_until_all_status(&session_, 3000, &request_id, &status, 1);
ASSERT_EQ(UXR_STATUS_OK, status);
ASSERT_TRUE(received_ok);
ASSERT_EQ(last_topic_object_id_, datareader_id);
ASSERT_EQ(last_topic_stream_id_, input_stream_id);
ASSERT_EQ(last_topic_request_id_, request_id);
ASSERT_EQ(UXR_STATUS_OK, last_status_);
ASSERT_EQ(datareader_id, last_status_object_id_);
ASSERT_EQ(request_id, last_status_request_id_);
}
}
void init_transport(int transport, const char* ip, uint16_t port)
{
switch(transport)
{
case UDP_TRANSPORT:
mtu_ = UXR_CONFIG_UDP_TRANSPORT_MTU;
ASSERT_TRUE(uxr_init_udp_transport(&udp_transport_, &udp_platform_, ip, port));
uxr_init_session(&session_, gateway_.monitorize(&udp_transport_.comm), client_key_);
break;
case TCP_TRANSPORT:
mtu_ = UXR_CONFIG_TCP_TRANSPORT_MTU;
ASSERT_TRUE(uxr_init_tcp_transport(&tcp_transport_, &tcp_platform_, ip, port));
uxr_init_session(&session_, gateway_.monitorize(&tcp_transport_.comm), client_key_);
break;
}
init_common();
}
void close_transport(int transport)
{
bool deleted = uxr_delete_session(&session_);
if(0.0f == gateway_.get_lost_value()) //because the agent only send one status to a delete in stream 0.
{
EXPECT_TRUE(deleted);
EXPECT_EQ(UXR_STATUS_OK, session_.info.last_requested_status);
}
switch(transport)
{
case UDP_TRANSPORT:
ASSERT_TRUE(uxr_close_udp_transport(&udp_transport_));
break;
case TCP_TRANSPORT:
ASSERT_TRUE(uxr_close_tcp_transport(&tcp_transport_));
break;
}
}
size_t get_mtu() const
{
return mtu_;
}
private:
void init_common()
{
/* Setup callback. */
uxr_set_topic_callback(&session_, on_topic_dispatcher, this);
uxr_set_status_callback(&session_, on_status_dispatcher, this);
/* Create session. */
ASSERT_TRUE(uxr_create_session(&session_));
ASSERT_EQ(UXR_STATUS_OK, session_.info.last_requested_status);
/* Setup streams. */
output_best_effort_stream_buffer_.reset(new uint8_t[mtu_ * UXR_CONFIG_MAX_OUTPUT_BEST_EFFORT_STREAMS]{0});
output_reliable_stream_buffer_.reset(new uint8_t[mtu_ * history_ * UXR_CONFIG_MAX_OUTPUT_RELIABLE_STREAMS]{0});
input_reliable_stream_buffer_.reset(new uint8_t[mtu_ * history_ * UXR_CONFIG_MAX_INPUT_RELIABLE_STREAMS]{0});
for(size_t i = 0; i < UXR_CONFIG_MAX_OUTPUT_BEST_EFFORT_STREAMS; ++i)
{
uint8_t* buffer = output_best_effort_stream_buffer_.get() + mtu_ * i;
(void) uxr_create_output_best_effort_stream(&session_, buffer, mtu_);
}
for(size_t i = 0; i < UXR_CONFIG_MAX_INPUT_BEST_EFFORT_STREAMS; ++i)
{
(void) uxr_create_input_best_effort_stream(&session_);
}
for(size_t i = 0; i < UXR_CONFIG_MAX_OUTPUT_RELIABLE_STREAMS; ++i)
{
uint8_t* buffer = output_reliable_stream_buffer_.get() + mtu_ * history_ * i;
(void) uxr_create_output_reliable_stream(&session_, buffer , mtu_ * history_, history_);
}
for(size_t i = 0; i < UXR_CONFIG_MAX_INPUT_RELIABLE_STREAMS; ++i)
{
uint8_t* buffer = input_reliable_stream_buffer_.get() + mtu_ * history_ * i;
(void) uxr_create_input_reliable_stream(&session_, buffer, mtu_ * history_, history_);
}
}
static void on_topic_dispatcher(uxrSession* session_, uxrObjectId object_id, uint16_t request_id, uxrStreamId stream_id, struct ucdrBuffer* serialization, void* args)
{
static_cast<Client*>(args)->on_topic(session_, object_id, request_id, stream_id, serialization);
}
void on_topic(uxrSession* session, uxrObjectId object_id, uint16_t request_id, uxrStreamId stream_id, struct ucdrBuffer* serialization)
{
(void) session;
BigHelloWorld topic;
BigHelloWorld_deserialize_topic(serialization, &topic);
ASSERT_EQ(expected_topic_index_, topic.index);
ASSERT_STREQ(expected_message_.c_str(), topic.message);
last_topic_object_id_ = object_id;
last_topic_stream_id_ = stream_id;
last_topic_request_id_ = request_id;
expected_topic_index_++;
std::cout << "topic received: " << topic.index << std::endl;
}
static void on_status_dispatcher(uxrSession* session_, uxrObjectId object_id, uint16_t request_id, uint8_t status, void* args)
{
static_cast<Client*>(args)->on_status(session_, object_id, request_id, status);
}
void on_status(uxrSession* session, uxrObjectId object_id, uint16_t request_id, uint8_t status)
{
(void) session;
last_status_ = status;
last_status_object_id_ = object_id;
last_status_request_id_ = request_id;
}
static uint32_t next_client_key_;
static const char* participant_xml_;
static const char* topic_xml_;
static const char* publisher_xml_;
static const char* subscriber_xml_;
static const char* datawriter_xml_;
static const char* datareader_xml_;
Gateway gateway_;
uint32_t client_key_;
uint16_t history_;
uxrUDPTransport udp_transport_;
uxrUDPPlatform udp_platform_;
uxrTCPTransport tcp_transport_;
uxrTCPPlatform tcp_platform_;
size_t mtu_;
uxrSession session_;
std::unique_ptr<uint8_t> output_best_effort_stream_buffer_;
std::unique_ptr<uint8_t> output_reliable_stream_buffer_;
std::unique_ptr<uint8_t> input_reliable_stream_buffer_;
std::string expected_message_;
uint8_t last_status_;
uxrObjectId last_status_object_id_;
uint16_t last_status_request_id_;
uxrObjectId last_topic_object_id_;
uxrStreamId last_topic_stream_id_;
uint16_t last_topic_request_id_;
size_t expected_topic_index_;
};
#endif //IN_TEST_CLIENT_HPP

View File

@ -1 +0,0 @@
#include "Discovery.hpp"

View File

@ -1,74 +0,0 @@
#ifndef IN_TEST_DISCOVERY_HPP
#define IN_TEST_DISCOVERY_HPP
#include "BigHelloWorld.h"
#include "Gateway.hpp"
#include "Client.hpp"
#include <uxr/client/client.h>
#include <ucdr/microcdr.h>
#include <gtest/gtest.h>
#include <iostream>
#include <thread>
class Discovery
{
public:
Discovery(int transport, const std::vector<uint16_t>& agent_ports)
: ip_("127.0.0.1")
, agent_ports_(agent_ports)
, transport_(transport)
{
}
void unicast(const std::vector<uint16_t>& discovery_ports)
{
std::vector<uxrAgentAddress> agent_list;
for(uint16_t it : discovery_ports)
{
agent_list.emplace_back(uxrAgentAddress{ip_.c_str(), it});
}
uxr_discovery_agents(1, 1000, on_agent_found, this, agent_list.data(), agent_list.size());
ASSERT_TRUE(agent_ports_.empty());
}
void multicast()
{
uxr_discovery_agents_default(1, 1000, on_agent_found, this);
ASSERT_TRUE(agent_ports_.empty());
}
private:
static void on_agent_found(const uxrAgentAddress* address, void* args)
{
static_cast<Discovery*>(args)->on_agent_found_member(address);
}
void on_agent_found_member(const uxrAgentAddress* address)
{
std::cout << "Agent found on port: " << address->port << std::endl;
std::vector<uint16_t>::iterator it = std::find(agent_ports_.begin(), agent_ports_.end(), address->port);
bool found = it != agent_ports_.end();
if(found)
{
Client client(0.0f, 1);
std::cout << "Client connecting to " << address->port << std::endl;
client.init_transport(transport_, address->ip, address->port);
client.close_transport(transport_);
agent_ports_.erase(it);
}
//ASSERT_TRUE(found); //in multicast, it is possible to read agents out of the tests that will not be found.
}
std::string ip_;
std::vector<uint16_t> agent_ports_;
int transport_;
};
#endif //IN_TEST_DISCOVERY_HPP

View File

@ -1,4 +0,0 @@
#include "Gateway.hpp"
std::uniform_real_distribution<float> Gateway::msg_lost_(0.0f, 1.0f);

View File

@ -1,111 +0,0 @@
#ifndef IN_TEST_GATEWAY_HPP
#define IN_TEST_GATEWAY_HPP
#include <iostream>
#include <random>
#include <chrono>
#include <uxr/client/core/communication/communication.h>
class Gateway
{
public:
Gateway(float lost)
: user_comm_(nullptr)
, lost_(lost)
{
std::random_device rd;
random_.seed(rd());
}
virtual ~Gateway()
{
}
uxrCommunication* monitorize(uxrCommunication* user_comm)
{
user_comm_ = user_comm;
communication_.instance = this;
communication_.send_msg = send_dispatcher;
communication_.recv_msg = recv_dispatcher;
communication_.comm_error = user_comm->comm_error;
communication_.mtu = user_comm->mtu;
return &communication_;
}
float get_lost_value() const
{
return lost_;
}
private:
static const size_t MESSAGE_LENGTH = 4096;
static std::uniform_real_distribution<float> msg_lost_;
static bool send_dispatcher(void* instance, const uint8_t* buf, size_t len)
{
return static_cast<Gateway*>(instance)->send(buf, len);
}
static bool recv_dispatcher(void* instance, uint8_t** buf, size_t* len, int timeout)
{
return static_cast<Gateway*>(instance)->recv(buf, len, timeout);
}
bool send(const uint8_t* buf, size_t len)
{
if(get_lost())
{
std::cout << "[Message from client lost -> " << len << " bytes lost]" << std::endl;
return false;
}
return user_comm_->send_msg(user_comm_->instance, buf, len);
}
bool recv(uint8_t** buf, size_t* len, int timeout)
{
int poll = timeout;
do
{
std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
bool result = user_comm_->recv_msg(user_comm_->instance, buf, len, timeout);
std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
poll -= static_cast<int>(std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count());
if(result)
{
if(get_lost())
{
std::cout << "[Message from agent lost -> " << *len << " bytes lost]" << std::endl;
}
else
{
return result;
}
}
}
while(0 < poll);
return false;
}
bool get_lost()
{
if(msg_lost_(random_) < lost_)
{
return true;
}
return false;
}
std::mt19937 random_;
uxrCommunication* user_comm_;
uxrCommunication communication_;
float lost_;
};
#endif //IN_TEST_GATEWAY

2
thirdparty/microcdr vendored

@ -1 +1 @@
Subproject commit 731adf730d7ea9eb5dbb52307ba91d911a1cdca5
Subproject commit 925348832bdd2f5975bb4acd8b16014ea681c22a

16
toolchains/CMakeLists.txt Normal file
View File

@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.5)
project(nuttx_toolchain NONE)
# Makefile flags
set(CROSSDEV "" CACHE STRING "GCC compiler use in NuttX.")
set(ARCH_CPU_FLAGS "" CACHE STRING "Makefile arquitecture flags.")
set(ARCH_OPT_FLAGS "" CACHE STRING "Makefile optimization flags.")
#separate_arguments(ARCH_CPU_FLAGS)
#separate_arguments(ARCH_OPT_FLAGS)
# Generate toolchain
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nuttx_toolchain.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/nuttx_toolchain.cmake
@ONLY
)

View File

@ -8,30 +8,23 @@ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
# Makefile flags
set(CROSSDEV "" CACHE STRING "GCC compiler use in NuttX.")
set(ARCH_CPU_FLAGS "" CACHE STRING "Makefile arquitecture flags.")
set(ARCH_OPT_FLAGS "" CACHE STRING "Makefile optimization flags.")
separate_arguments(ARCH_CPU_FLAGS)
separate_arguments(ARCH_OPT_FLAGS)
# Compiler tools
foreach(tool gcc ld ar)
string(TOUPPER ${tool} TOOL)
find_program(${TOOL} ${CROSSDEV}${tool})
find_program(${TOOL} @CROSSDEV@${tool})
if(NOT ${TOOL})
message(FATAL_ERROR "could not find ${tool}")
endif()
endforeach()
CMAKE_FORCE_C_COMPILER(${CROSSDEV}gcc GNU)
CMAKE_FORCE_CXX_COMPILER(${CROSSDEV}g++ GNU)
CMAKE_FORCE_C_COMPILER(@CROSSDEV@gcc GNU)
CMAKE_FORCE_CXX_COMPILER(@CROSSDEV@g++ GNU)
include_directories(SYSTEM ${CMAKE_SYSROOT}/include)
add_compile_options(
-std=c99
${ARCH_CPU_FLAGS}
${ARCH_OPT_FLAGS}
@ARCH_CPU_FLAGS@
@ARCH_OPT_FLAGS@
)
set(__BIG_ENDIAN__ 0)