Skip to content

Commit

Permalink
Fix read_cdr and take_cdr
Browse files Browse the repository at this point in the history
They returned only ever Empty CDR blobs because the blob kind wasn't getting set.

Signed-off-by: Erik Boasson <[email protected]>
  • Loading branch information
eboasson committed Apr 4, 2024
1 parent a521df2 commit 43d0ee4
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions src/ddscxx/include/dds/sub/detail/SamplesHolder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,31 @@ class CDRSamplesHolder : public SamplesHolder

void append_sample(void *sample, const dds_sample_info_t *si)
{
ddsrt_iovec_t blob_content;
ddscxx_serdata<org::eclipse::cyclonedds::topic::CDRBlob> *sd;
org::eclipse::cyclonedds::topic::CDRBlob emptyBlob;
dds::sub::Sample<org::eclipse::cyclonedds::topic::CDRBlob, dds::sub::detail::Sample> *buffer;

sd = static_cast<ddscxx_serdata<org::eclipse::cyclonedds::topic::CDRBlob> *>(sample);
dds::sub::Sample<org::eclipse::cyclonedds::topic::CDRBlob, dds::sub::detail::Sample> blob_ssmple(
emptyBlob, sample_info_from_c(si));
samples_.delegate()->append_sample(blob_ssmple);
ddsi_serdata_to_ser_ref(sd, 0, ddsi_serdata_size(sd), &blob_content);
buffer = samples_.delegate()->get_buffer();
org::eclipse::cyclonedds::topic::CDRBlob &sample_data = buffer[samples_.length() - 1].delegate().data();
copy_buffer_to_cdr_blob(reinterpret_cast<uint8_t *>(blob_content.iov_base),
blob_content.iov_len, sample_data.kind(), sample_data);
ddsi_serdata_to_ser_unref(sd, &blob_content);
ddsrt_iovec_t blob_content;
if (ddsi_serdata_to_ser_ref(sd, 0, ddsi_serdata_size(sd), &blob_content)) {
org::eclipse::cyclonedds::topic::CDRBlob emptyBlob;
switch (sd->kind) {
case SDK_EMPTY:
break;
case SDK_KEY:
emptyBlob.kind(org::eclipse::cyclonedds::topic::BlobKind::KeyOnly);
break;
case SDK_DATA:
emptyBlob.kind(org::eclipse::cyclonedds::topic::BlobKind::Data);
break;
}
dds::sub::Sample<org::eclipse::cyclonedds::topic::CDRBlob, dds::sub::detail::Sample> blob_sample(
emptyBlob, sample_info_from_c(si));
samples_.delegate()->append_sample(blob_sample);
dds::sub::Sample<org::eclipse::cyclonedds::topic::CDRBlob, dds::sub::detail::Sample> *buffer;
buffer = samples_.delegate()->get_buffer();
org::eclipse::cyclonedds::topic::CDRBlob &sample_data = buffer[samples_.length() - 1].delegate().data();
copy_buffer_to_cdr_blob(reinterpret_cast<uint8_t *>(blob_content.iov_base),
blob_content.iov_len, sample_data.kind(), sample_data);
ddsi_serdata_to_ser_unref(sd, &blob_content);
}
}

private:
Expand Down

0 comments on commit 43d0ee4

Please sign in to comment.