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

Fix error in read_sample()/take_sample() operations with Datasharing [12130] #2070

Merged
merged 7 commits into from
Jul 19, 2021
Merged
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
5 changes: 3 additions & 2 deletions src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,6 @@ struct ReadTakeCommand
CacheChange_t* change,
bool& deserialization_error)
{
// Mark that some data is available
return_value_ = ReturnCode_t::RETCODE_OK;
bool ret_val = false;
deserialization_error = false;

Expand All @@ -297,6 +295,9 @@ struct ReadTakeCommand
deserialization_error = true;
return false;
}

// Mark that some data is available
return_value_ = ReturnCode_t::RETCODE_OK;
richiware marked this conversation as resolved.
Show resolved Hide resolved
}

++current_slot_;
Expand Down
52 changes: 35 additions & 17 deletions test/blackbox/types/Data1mbType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,49 @@ bool Data1mbType::serialize(
void* data,
SerializedPayload_t* payload)
{
bool ret_value = false;
Data1mb* p_type = (Data1mb*) data;
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->max_size); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR);
payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
// Serialize encapsulation
ser.serialize_encapsulation();
p_type->serialize(ser); // Serialize the object:
payload->length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length
return true;

try
{
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->max_size); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR);
payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
// Serialize encapsulation
ser.serialize_encapsulation();
p_type->serialize(ser); // Serialize the object:
payload->length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length
ret_value = true;
}
catch (eprosima::fastcdr::exception::Exception&)
{
}
return ret_value;
}

bool Data1mbType::deserialize(
SerializedPayload_t* payload,
void* data)
{
bool ret_value = false;
Data1mb* p_type = (Data1mb*) data; //Convert DATA to pointer of your type
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data.
// Deserialize encapsulation.
deser.read_encapsulation();
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
p_type->deserialize(deser);//Deserialize the object:
return true;

try
{
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data.
// Deserialize encapsulation.
deser.read_encapsulation();
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
p_type->deserialize(deser);//Deserialize the object:
ret_value = true;
}
catch (eprosima::fastcdr::exception::Exception&)
{
}
return ret_value;
}

void* Data1mbType::createData()
Expand Down
52 changes: 35 additions & 17 deletions test/blackbox/types/Data64kbType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,49 @@ bool Data64kbType::serialize(
void* data,
SerializedPayload_t* payload)
{
bool ret_value = false;
Data64kb* p_type = (Data64kb*) data;
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->max_size); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR);
payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
// Serialize encapsulation
ser.serialize_encapsulation();
p_type->serialize(ser); // Serialize the object:
payload->length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length
return true;

try
{
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->max_size); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR);
payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
// Serialize encapsulation
ser.serialize_encapsulation();
p_type->serialize(ser); // Serialize the object:
payload->length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length
ret_value = true;
}
catch (eprosima::fastcdr::exception::Exception&)
{
}
return ret_value;
}

bool Data64kbType::deserialize(
SerializedPayload_t* payload,
void* data)
{
bool ret_value = false;
Data64kb* p_type = (Data64kb*) data; //Convert DATA to pointer of your type
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data.
// Deserialize encapsulation.
deser.read_encapsulation();
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
p_type->deserialize(deser); //Deserialize the object:
return true;

try
{
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length); // Object that manages the raw buffer.
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data.
// Deserialize encapsulation.
deser.read_encapsulation();
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
p_type->deserialize(deser); //Deserialize the object:
ret_value = true;
}
catch (eprosima::fastcdr::exception::Exception&)
{
}
return ret_value;
}

std::function<uint32_t()> Data64kbType::getSerializedSizeProvider(
Expand Down
63 changes: 40 additions & 23 deletions test/blackbox/types/HelloWorldType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,54 @@ bool HelloWorldType::serialize(
void* data,
SerializedPayload_t* payload)
{
bool ret_value = false;
HelloWorld* hw = (HelloWorld*) data;
// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->max_size);
// Object that serializes the data.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR);
payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
// Serialize encapsulation
ser.serialize_encapsulation();
//serialize the object:
hw->serialize(ser);
payload->length = (uint32_t)ser.getSerializedDataLength();
return true;

try
{
// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->max_size);
// Object that serializes the data.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR);
payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
// Serialize encapsulation
ser.serialize_encapsulation();
//serialize the object:
hw->serialize(ser);
payload->length = (uint32_t)ser.getSerializedDataLength();
ret_value = true;
}
catch (eprosima::fastcdr::exception::Exception&)
{
}
return ret_value;
}

bool HelloWorldType::deserialize(
SerializedPayload_t* payload,
void* data)
{
bool ret_value = false;
HelloWorld* hw = (HelloWorld*) data;
// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length);
// Object that serializes the data.
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data.
// Deserialize encapsulation.
deser.read_encapsulation();
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
//serialize the object:
hw->deserialize(deser);
return true;
try
{
// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length);
// Object that serializes the data.
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data.
// Deserialize encapsulation.
deser.read_encapsulation();
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
//serialize the object:
hw->deserialize(deser);
ret_value = true;
}
catch (eprosima::fastcdr::exception::Exception&)
{
}
return ret_value;
}

std::function<uint32_t()> HelloWorldType::getSerializedSizeProvider(
Expand Down
64 changes: 41 additions & 23 deletions test/blackbox/types/StringType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,37 +41,55 @@ bool StringType::serialize(
void* data,
SerializedPayload_t* payload)
{
bool ret_value = false;
String* hw = (String*) data;
// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->max_size);
// Object that serializes the data.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR);
payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
// Serialize encapsulation
ser.serialize_encapsulation();
//serialize the object:
hw->serialize(ser);
payload->length = (uint32_t)ser.getSerializedDataLength();
return true;

try
{
// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->max_size);
// Object that serializes the data.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR);
payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
// Serialize encapsulation
ser.serialize_encapsulation();
//serialize the object:
hw->serialize(ser);
payload->length = (uint32_t)ser.getSerializedDataLength();
ret_value = true;
}
catch (eprosima::fastcdr::exception::Exception&)
{
}
return ret_value;
}

bool StringType::deserialize(
SerializedPayload_t* payload,
void* data)
{
bool ret_value = false;
String* hw = (String*) data;
// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length);
// Object that serializes the data.
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data.
// Deserialize encapsulation.
deser.read_encapsulation();
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
//serialize the object:
hw->deserialize(deser);
return true;

try
{
// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer((char*)payload->data, payload->length);
// Object that serializes the data.
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
eprosima::fastcdr::Cdr::DDS_CDR); // Object that deserializes the data.
// Deserialize encapsulation.
deser.read_encapsulation();
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
//serialize the object:
hw->deserialize(deser);
ret_value = true;
}
catch (eprosima::fastcdr::exception::Exception&)
{
}
return ret_value;
}

std::function<uint32_t()> StringType::getSerializedSizeProvider(
Expand Down
Loading