Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error sending the sample when using XCDR2 #4942

Open
1 task done
i-and opened this issue Jun 12, 2024 · 1 comment
Open
1 task done

Error sending the sample when using XCDR2 #4942

i-and opened this issue Jun 12, 2024 · 1 comment
Labels
bug Issue to report a bug

Comments

@i-and
Copy link

i-and commented Jun 12, 2024

Is there an already existing issue for this?

  • I have searched the existing issues

Expected behavior

The sample is successfully sent regardless of its size.

Current behavior

Depending on the size of the sample, the write() method returns an error code.

Steps to reproduce

This error can be reproduced by modifying HelloWorldExample as follows:

diff --git a/examples/cpp/dds/HelloWorldExample/HelloWorldPublisher.cpp b/examples/cpp/dds/HelloWorldExample/HelloWorldPublisher.cpp
index 86f3e0009..aeaa239d6 100644
--- a/examples/cpp/dds/HelloWorldExample/HelloWorldPublisher.cpp
+++ b/examples/cpp/dds/HelloWorldExample/HelloWorldPublisher.cpp
@@ -43,7 +43,7 @@ bool HelloWorldPublisher::init(
         bool use_env)
 {
     hello_.index(0);
-    hello_.message("HelloWorld");
+    hello_.message().resize(256, 'A');
     DomainParticipantQos pqos = PARTICIPANT_QOS_DEFAULT;
     pqos.name("Participant_pub");
     auto factory = DomainParticipantFactory::get_instance();
@@ -106,6 +106,7 @@ bool HelloWorldPublisher::init(
     {
         publisher_->get_default_datawriter_qos(wqos);
     }
+    wqos.representation().m_value.push_back(XCDR2_DATA_REPRESENTATION);
 
     writer_ = publisher_->create_datawriter(
         topic_,
@@ -218,7 +219,9 @@ bool HelloWorldPublisher::publish(
     if (listener_.firstConnected_ || !waitForListener || listener_.matched_ > 0)
     {
         hello_.index(hello_.index() + 1);
-        writer_->write(&hello_);
+        if (!writer_->write(&hello_)) {
+            printf("ERROR WRITE SAMPLE!!!\n");
+        }
         return true;
     }
     return false;
diff --git a/examples/cpp/dds/HelloWorldExample/HelloWorldSubscriber.cpp b/examples/cpp/dds/HelloWorldExample/HelloWorldSubscriber.cpp
index 6823a32f4..145ba4d9f 100644
--- a/examples/cpp/dds/HelloWorldExample/HelloWorldSubscriber.cpp
+++ b/examples/cpp/dds/HelloWorldExample/HelloWorldSubscriber.cpp
@@ -106,6 +106,8 @@ bool HelloWorldSubscriber::init(
         subscriber_->get_default_datareader_qos(rqos);
     }
 
+    rqos.type_consistency().representation.m_value.push_back(XCDR2_DATA_REPRESENTATION);
+
     reader_ = subscriber_->create_datareader(topic_, rqos, &listener_);
 
     if (reader_ == nullptr)
diff --git a/examples/cpp/dds/HelloWorldExample/HelloWorld_main.cpp b/examples/cpp/dds/HelloWorldExample/HelloWorld_main.cpp
index 35870eb67..bcaebd3cd 100644
--- a/examples/cpp/dds/HelloWorldExample/HelloWorld_main.cpp
+++ b/examples/cpp/dds/HelloWorldExample/HelloWorld_main.cpp
@@ -291,6 +291,8 @@ int main(
         }
     }
 
+    Log::SetVerbosity(Log::Kind::Warning);
+
     switch (type)
     {
         case 1:

Fast DDS version/commit

v2.14.1

Platform/Architecture

Ubuntu Focal 20.04 amd64

Transport layer

Default configuration, UDPv4 & SHM

Additional context

No response

XML configuration file

No response

Relevant log output

2024-06-12 20:47:00.881 [DATA_WRITER Warning] Data serialization returned false -> Function perform_create_new_change
ERROR WRITE SAMPLE!!!
Message: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA with index: 4 SENT

Network traffic capture

No response

@i-and i-and added the triage Issue pending classification label Jun 12, 2024
@elianalf
Copy link
Contributor

Hi @i-and,
Thank you for using Fast DDS.

There might be an issue with the data serialization in case the message size is greater than 255 and the extensibility of the message type defined in the .idl is APPENDABLE, which is by default. I will label it as bug. In the meanwhile, you can still accomplish what you are trying to do, setting the extensibility to FINAL in the HelloWorld.idl file as follow:

@final
struct HelloWorld
{
	unsigned long index;
	string message;
};

and regenerate the types with Fast DDS-GEN. If you haven't installed it yet, you can follow the installation instructions and then the usage guide to regenerate types adding the -replace argument.

@elianalf elianalf added bug Issue to report a bug and removed triage Issue pending classification labels Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue to report a bug
Projects
None yet
Development

No branches or pull requests

2 participants