Skip to content
Open
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
3 changes: 3 additions & 0 deletions data/json/union_bitmask.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"x1":128
}
49 changes: 49 additions & 0 deletions src/cxx/makefile_eprosima_fastdds_linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
######################################################################
# To compile, type:
# make -f makefile_eprosima_fastdds_linux
#
# This makefile assumes that your build environment is already correctly
# configured. (For example, the correct version of your compiler and
# linker should be on your PATH.)
#
# You should set the environment variable FASTDDS_HOME to point to where
# eProsima Fast DDS is installed:
# colcon build --merge-install --install-dir <directory>
# export FASTDDS_HOME=<directory>
#
######################################################################

COMPILER = g++
COMPILER_FLAGS = -std=c++17 -Wall -Wextra -m64
LINKER = g++
LINKER_FLAGS = -m64 -Wl,--no-as-needed
SYSLIBS = -ldl -lm -lpthread -lrt

DEFINES = -DEPROSIMA_FAST_DDS

ifndef FASTDDS_HOME
$(error FASTDDS_HOME not defined. Set it to your Fast DDS installation directory.)
endif

INCLUDES = -I. \
-I$(FASTDDS_HOME)/include

LIBS = -L$(FASTDDS_HOME)/lib -lfastdds -lfastcdr \
$(SYSLIBS)

EXEC = fastdds_pro_linux64
OBJDIR = objs/fastdds_pro

$(OBJDIR)/$(EXEC): $(OBJDIR) $(OBJDIR)/test_main.o
$(LINKER) $(LINKER_FLAGS) -o $@ $(OBJDIR)/test_main.o $(LIBS)

$(OBJDIR)/test_main.o: test_main.cxx variant_eprosima_fastdds.h
$(COMPILER) $(COMPILER_FLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@

$(OBJDIR):
mkdir -p $(OBJDIR)

clean:
rm -rf $(OBJDIR)

.PHONY: clean
115 changes: 111 additions & 4 deletions src/cxx/test_main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "variant_toc_coredx_dds.hh"
#elif defined(OPENDDS)
#include "variant_opendds.h"
#elif defined(EPROSIMA_FAST_DDS)
#include "variant_eprosima_fastdds.h"
#else
#error "Must define the DDS vendor"
#endif
Expand Down Expand Up @@ -930,16 +932,26 @@ class TestOptions {
class DPListener : public DomainParticipantListener
{
public:
void on_inconsistent_topic (Topic *topic, const InconsistentTopicStatus &) {
#if defined(EPROSIMA_FAST_DDS)
void on_inconsistent_topic(Topic *topic, InconsistentTopicStatus) {
FDDS_DECLARE_NAMES(topic);
#else
void on_inconsistent_topic(Topic *topic, const InconsistentTopicStatus &) {
const char *topic_name = topic->get_name();
const char *type_name = topic->get_type_name();
#endif
printf("%s() topic: '%s' type: '%s'\n", __FUNCTION__, topic_name, type_name);
fflush(stdout);
}

void on_offered_incompatible_qos(DataWriter *dw, const OfferedIncompatibleQosStatus & status) {
Topic *topic = dw->get_topic( );
#if defined(EPROSIMA_FAST_DDS)
FDDS_DECLARE_NAMES(topic);
#else
const char *topic_name = topic->get_name( );
const char *type_name = topic->get_type_name( );
#endif
const char *policy_name = NULL;
policy_name = get_qos_policy_name(status.last_policy_id);
printf("%s() topic: '%s' type: '%s' : %d (%s)\n", __FUNCTION__,
Expand All @@ -950,32 +962,49 @@ class DPListener : public DomainParticipantListener

void on_publication_matched (DataWriter *dw, const PublicationMatchedStatus & status) {
Topic *topic = dw->get_topic( );
#if defined(EPROSIMA_FAST_DDS)
FDDS_DECLARE_NAMES(topic);
#else
const char *topic_name = topic->get_name( );
const char *type_name = topic->get_type_name( );
#endif
printf("%s() topic: '%s' type: '%s' : matched readers %d (change = %d)\n", __FUNCTION__,
topic_name, type_name, status.current_count, status.current_count_change);
}

void on_offered_deadline_missed (DataWriter *dw, const OfferedDeadlineMissedStatus & status) {
Topic *topic = dw->get_topic( );
#if defined(EPROSIMA_FAST_DDS)
FDDS_DECLARE_NAMES(topic);
#else
const char *topic_name = topic->get_name( );
const char *type_name = topic->get_type_name( );
#endif
printf("%s() topic: '%s' type: '%s' : (total = %d, change = %d)\n", __FUNCTION__,
topic_name, type_name, status.total_count, status.total_count_change);
}

void on_liveliness_lost (DataWriter *dw, const LivelinessLostStatus & status) {
Topic *topic = dw->get_topic( );
#if defined(EPROSIMA_FAST_DDS)
FDDS_DECLARE_NAMES(topic);
#else
const char *topic_name = topic->get_name( );
const char *type_name = topic->get_type_name( );
#endif
printf("%s() topic: '%s' type: '%s' : (total = %d, change = %d)\n", __FUNCTION__,
topic_name, type_name, status.total_count, status.total_count_change);
}

void on_requested_incompatible_qos (DataReader *dr, const RequestedIncompatibleQosStatus & status) {
#if defined(EPROSIMA_FAST_DDS)
const TopicDescription *td = dr->get_topicdescription( );
FDDS_DECLARE_NAMES(td);
#else
TopicDescription *td = dr->get_topicdescription( );
const char *topic_name = td->get_name( );
const char *type_name = td->get_type_name( );
#endif
const char *policy_name = NULL;
policy_name = get_qos_policy_name(status.last_policy_id);
printf("%s() topic: '%s' type: '%s' : %d (%s)\n", __FUNCTION__,
Expand All @@ -984,25 +1013,40 @@ class DPListener : public DomainParticipantListener
}

void on_subscription_matched (DataReader *dr, const SubscriptionMatchedStatus & status) {
#if defined(EPROSIMA_FAST_DDS)
const TopicDescription *td = dr->get_topicdescription( );
FDDS_DECLARE_NAMES(td);
#else
TopicDescription *td = dr->get_topicdescription( );
const char *topic_name = td->get_name( );
const char *type_name = td->get_type_name( );
#endif
printf("%s() topic: '%s' type: '%s' : matched writers %d (change = %d)\n", __FUNCTION__,
topic_name, type_name, status.current_count, status.current_count_change);
}

void on_requested_deadline_missed (DataReader *dr, const RequestedDeadlineMissedStatus & status) {
#if defined(EPROSIMA_FAST_DDS)
const TopicDescription *td = dr->get_topicdescription( );
FDDS_DECLARE_NAMES(td);
#else
TopicDescription *td = dr->get_topicdescription( );
const char *topic_name = td->get_name( );
const char *type_name = td->get_type_name( );
#endif
printf("%s() topic: '%s' type: '%s' : (total = %d, change = %d)\n", __FUNCTION__,
topic_name, type_name, status.total_count, status.total_count_change);
}

void on_liveliness_changed (DataReader *dr, const LivelinessChangedStatus & status) {
#if defined(EPROSIMA_FAST_DDS)
const TopicDescription *td = dr->get_topicdescription( );
FDDS_DECLARE_NAMES(td);
#else
TopicDescription *td = dr->get_topicdescription( );
const char *topic_name = td->get_name( );
const char *type_name = td->get_type_name( );
#endif
printf("%s() topic: '%s' type: '%s' : (alive = %d, not_alive = %d)\n", __FUNCTION__,
topic_name, type_name, status.alive_count, status.not_alive_count);
}
Expand Down Expand Up @@ -1096,7 +1140,12 @@ class TestApplication {
}

printf("Create topic: %s\n", options->topic_name );
fflush(stdout);
#if defined(EPROSIMA_FAST_DDS)
topic = dp->create_topic( options->topic_name, FDDS_REGISTERED_TYPE_NAME, TOPIC_QOS_DEFAULT, nullptr, LISTENER_STATUS_MASK_ALL);
#else
topic = dp->create_topic( options->topic_name, options->type_name, TOPIC_QOS_DEFAULT, NULL, 0);
#endif
if (topic == NULL) {
logger.log_message("failed to create topic", Verbosity::ERROR);
return false;
Expand Down Expand Up @@ -1130,10 +1179,18 @@ class TestApplication {

dp->get_default_publisher_qos( pub_qos );
if ( options->partition != NULL ) {
#if defined(EPROSIMA_FAST_DDS)
StringSeq_push(pub_qos.partition(), options->partition);
#else
StringSeq_push(pub_qos.partition.name, options->partition);
#endif
}

#if defined(EPROSIMA_FAST_DDS)
pub = dp->create_publisher(pub_qos, nullptr, LISTENER_STATUS_MASK_NONE);
#else
pub = dp->create_publisher(pub_qos, NULL, 0);
#endif
if (pub == NULL) {
logger.log_message("failed to create publisher", Verbosity::ERROR);
return false;
Expand All @@ -1155,8 +1212,14 @@ class TestApplication {
#elif defined(TWINOAKS_COREDX) || defined(OPENDDS)
dw_qos.representation.value.length(1);
dw_qos.representation.value[0] = options->data_representation;
#elif defined(EPROSIMA_FAST_DDS)
dw_qos.representation.m_value = {options->data_representation};
#endif
#if defined(EPROSIMA_FAST_DDS)
logger.log_message(" Data_Representation = " + QosUtils::to_string(dw_qos.representation.m_value.empty() ? XCDR2_DATA_REPRESENTATION : dw_qos.representation.m_value[0]), Verbosity::DEBUG);
#else
logger.log_message(" Data_Representation = " + QosUtils::to_string(dw_qos.representation.value[0]), Verbosity::DEBUG);
#endif
if ( options->ownership_strength != -1 ) {
dw_qos.ownership.kind = EXCLUSIVE_OWNERSHIP_QOS;
dw_qos.ownership_strength.value = options->ownership_strength;
Expand Down Expand Up @@ -1195,8 +1258,12 @@ class TestApplication {
#endif

printf("Create writer for topic: %s type: %s\n", options->topic_name, options->type_name );

fflush(stdout);
#if defined(EPROSIMA_FAST_DDS)
dw = pub->create_datawriter( topic, dw_qos, &dp_listener, LISTENER_STATUS_MASK_ALL);
#else
dw = pub->create_datawriter( topic, dw_qos, NULL, 0);
#endif

if (dw == NULL) {
logger.log_message("failed to create datawriter", Verbosity::ERROR);
Expand All @@ -1216,10 +1283,18 @@ class TestApplication {

dp->get_default_subscriber_qos( sub_qos );
if ( options->partition != NULL ) {
#if defined(EPROSIMA_FAST_DDS)
StringSeq_push(sub_qos.partition(), options->partition);
#else
StringSeq_push(sub_qos.partition.name, options->partition);
#endif
}

#if defined(EPROSIMA_FAST_DDS)
sub = dp->create_subscriber( sub_qos, nullptr, LISTENER_STATUS_MASK_NONE );
#else
sub = dp->create_subscriber( sub_qos, NULL, 0 );
#endif
if (sub == NULL) {
logger.log_message("failed to create subscriber", Verbosity::ERROR);
return false;
Expand All @@ -1240,8 +1315,14 @@ class TestApplication {
#elif defined(TWINOAKS_COREDX) || defined(OPENDDS)
dr_qos.representation.value.length(1);
dr_qos.representation.value[0] = options->data_representation;
#elif defined(EPROSIMA_FAST_DDS)
dr_qos.representation.m_value = {options->data_representation};
#endif
#if defined(EPROSIMA_FAST_DDS)
logger.log_message(" DataRepresentation = " + QosUtils::to_string(dr_qos.representation.m_value.empty() ? XCDR2_DATA_REPRESENTATION : dr_qos.representation.m_value[0]), Verbosity::DEBUG);
#else
logger.log_message(" DataRepresentation = " + QosUtils::to_string(dr_qos.representation.value[0]), Verbosity::DEBUG);
#endif
if ( options->ownership_strength != -1 ) {
dr_qos.ownership.kind = EXCLUSIVE_OWNERSHIP_QOS;
}
Expand Down Expand Up @@ -1271,22 +1352,37 @@ class TestApplication {
logger.log_message(" HistoryDepth = " + std::to_string(dr_qos.history.depth), Verbosity::DEBUG);
}

#if defined(EPROSIMA_FAST_DDS)
dr_qos.type_consistency() = (DDS::FDDS_TypeConsistency_Real)options->type_consistency;
logger.log_message(" TypeConsistency * kind = " + QosUtils::to_string(options->type_consistency.kind), Verbosity::DEBUG );
logger.log_message(" * ignore_sequence_bounds = " + std::to_string(options->type_consistency.ignore_sequence_bounds ), Verbosity::DEBUG );
logger.log_message(" * ignore_string_bounds = " + std::to_string(options->type_consistency.ignore_string_bounds), Verbosity::DEBUG );
logger.log_message(" * ignore_member_names = " + std::to_string(options->type_consistency.ignore_member_names), Verbosity::DEBUG );
logger.log_message(" * prevent_type_widening = " + std::to_string(options->type_consistency.prevent_type_widening), Verbosity::DEBUG );
logger.log_message(" * force_type_validation = " + std::to_string(options->type_consistency.force_type_validation), Verbosity::DEBUG );
#else
dr_qos.type_consistency = options->type_consistency;
logger.log_message(" TypeConsistency * kind = " + QosUtils::to_string(dr_qos.type_consistency.kind), Verbosity::DEBUG );
logger.log_message(" * ignore_sequence_bounds = " + std::to_string(dr_qos.type_consistency.ignore_sequence_bounds ), Verbosity::DEBUG );
logger.log_message(" * ignore_string_bounds = " + std::to_string(dr_qos.type_consistency.ignore_string_bounds), Verbosity::DEBUG );
logger.log_message(" * ignore_member_names = " + std::to_string(dr_qos.type_consistency.ignore_member_names), Verbosity::DEBUG );
logger.log_message(" * prevent_type_widening = " + std::to_string(dr_qos.type_consistency.prevent_type_widening), Verbosity::DEBUG );
logger.log_message(" * force_type_validation = " + std::to_string(dr_qos.type_consistency.force_type_validation), Verbosity::DEBUG );
#endif

#if defined(TWINOAKS_COREDX)
if ( options->disable_type_info )
dr_qos.rtps_reader.send_typeobj_v2 = 0;
#endif

printf("Create reader for topic: %s\n", options->topic_name );

fflush(stdout);

#if defined(EPROSIMA_FAST_DDS)
dr = sub->create_datareader(topic, dr_qos, &dp_listener, LISTENER_STATUS_MASK_ALL);
#else
dr = sub->create_datareader(topic, dr_qos, NULL, LISTENER_STATUS_MASK_NONE);
#endif


if (dr == NULL) {
Expand All @@ -1307,7 +1403,9 @@ class TestApplication {

do {
DynamicDataReader * ddr = dynamic_cast<DDS::DynamicDataReader*>(dr);
#if defined(RTI_CONNEXT_DDS) || defined(OPENDDS) || defined(EPROSIMA_FAST_DDS) || defined(INTERCOM_DDS)
#if defined(EPROSIMA_FAST_DDS)
retval = fdds_take(ddr, samples, sample_infos);
#elif defined(RTI_CONNEXT_DDS) || defined(OPENDDS) || defined(INTERCOM_DDS)
retval = ddr->take ( samples,
sample_infos,
LENGTH_UNLIMITED,
Expand All @@ -1331,10 +1429,14 @@ class TestApplication {
#elif defined(TWINOAKS_COREDX)
DynamicData *sample = samples[i];
SampleInfo *sample_info = sample_infos[i];
#elif defined(EPROSIMA_FAST_DDS)
DynamicData *sample = &samples[i];
SampleInfo *sample_info = samples.get_info(i);
#endif

if (sample_info->valid_data) {
printf( "sample_received()\n" );
fflush(stdout);
print_data(sample);
if (check_data(sample, options->data_folder, options->data_file)) {
printf("Received sample is the same as loaded\n");
Expand All @@ -1348,6 +1450,8 @@ class TestApplication {
ddr->return_loan(samples, sample_infos);
#elif defined(TWINOAKS_COREDX)
ddr->return_loan( &samples, &sample_infos );
#elif defined(EPROSIMA_FAST_DDS)
samples.clear();
#endif
}
} while (retval == RETCODE_OK);
Expand Down Expand Up @@ -1378,6 +1482,8 @@ class TestApplication {
DynamicDataWriter *ddw = dynamic_cast<DynamicDataWriter *>(dw);
#if defined(RTI_CONNEXT_DDS)
ddw->write(*dd, HANDLE_NIL);
#elif defined(EPROSIMA_FAST_DDS)
fdds_write(ddw, dd, HANDLE_NIL);
#elif defined(TWINOAKS_COREDX)
ddw->write(dd, HANDLE_NIL);
#endif
Expand All @@ -1397,6 +1503,7 @@ class TestApplication {
/*************************************************************/
int main( int argc, char * argv[] )
{
setvbuf(stdout, nullptr, _IONBF, 0); // unbuffered stdout for pexpect pipe detection
install_sig_handlers();

TestOptions options;
Expand Down
Loading