Skip to content

Commit

Permalink
Use proper Micro-CDR API
Browse files Browse the repository at this point in the history
  • Loading branch information
pablogs9 committed Sep 23, 2021
1 parent 39192cf commit 7a8b9a4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
16 changes: 5 additions & 11 deletions src/discovery/ParticipantProxyData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,25 +121,21 @@ bool ParticipantProxyData::readFromUcdrBuffer(ucdrBuffer &buffer) {
}
case ParameterId::PID_ENTITY_NAME: {
// TODO
buffer.iterator += length;
buffer.last_data_size = 1;
ucdr_advance_buffer(&buffer, length);
break;
}
case ParameterId::PID_PROPERTY_LIST: {
// TODO
buffer.iterator += length;
buffer.last_data_size = 1;
ucdr_advance_buffer(&buffer, length);
break;
}
case ParameterId::PID_USER_DATA: {
// TODO
buffer.iterator += length;
buffer.last_data_size = 1;
ucdr_advance_buffer(&buffer, length);
break;
}
case ParameterId::PID_PAD: {
buffer.iterator += length;
buffer.last_data_size = 1;
ucdr_advance_buffer(&buffer, length);
break;
}
case ParameterId::PID_SENTINEL: {
Expand All @@ -148,9 +144,7 @@ bool ParticipantProxyData::readFromUcdrBuffer(ucdrBuffer &buffer) {
default: { return false; }
}
// Parameter lists are 4-byte aligned
uint32_t alignment = ucdr_buffer_alignment(&buffer, 4);
buffer.iterator += alignment;
buffer.last_data_size = 4;
ucdr_align_to(&buffer, 4);
}
return true;
}
Expand Down
6 changes: 2 additions & 4 deletions src/discovery/SPDPAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,15 +288,13 @@ void SPDPAgent::addParticipantParameters() {
ucdr_serialize_uint16_t(&m_microbuffer, protocolVersionSize + 2);
ucdr_serialize_uint8_t(&m_microbuffer, PROTOCOLVERSION.major);
ucdr_serialize_uint8_t(&m_microbuffer, PROTOCOLVERSION.minor);
m_microbuffer.iterator += 2; // padding
m_microbuffer.last_data_size = 4; // to 4 byte
ucdr_advance_buffer(&m_microbuffer, 2);

ucdr_serialize_uint16_t(&m_microbuffer, ParameterId::PID_VENDORID);
ucdr_serialize_uint16_t(&m_microbuffer, vendorIdSize + 2);
ucdr_serialize_array_uint8_t(&m_microbuffer,
Config::VENDOR_ID.vendorId.data(), vendorIdSize);
m_microbuffer.iterator += 2; // padding
m_microbuffer.last_data_size = 4; // to 4 byte
ucdr_advance_buffer(&m_microbuffer, 2);

ucdr_serialize_uint16_t(&m_microbuffer,
ParameterId::PID_DEFAULT_UNICAST_LOCATOR);
Expand Down
9 changes: 3 additions & 6 deletions src/discovery/TopicData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ bool TopicData::readFromUcdrBuffer(ucdrBuffer &buffer) {
case ParameterId::PID_RELIABILITY:
ucdr_deserialize_uint32_t(&buffer,
reinterpret_cast<uint32_t *>(&reliabilityKind));
buffer.iterator += 8;
ucdr_advance_buffer(&buffer, 8);
// TODO Skip 8 bytes. don't know what they are yet
break;
case ParameterId::PID_SENTINEL:
Expand All @@ -86,13 +86,10 @@ bool TopicData::readFromUcdrBuffer(ucdrBuffer &buffer) {
multicastLocator.readFromUcdrBuffer(buffer);
break;
default:
buffer.iterator += length;
buffer.last_data_size = 1;
ucdr_advance_buffer(&buffer, length);
}

uint32_t alignment = ucdr_buffer_alignment(&buffer, 4);
buffer.iterator += alignment;
buffer.last_data_size = 4; // 4 Byte alignment per element
ucdr_align_to(&buffer, 4);
}
return ucdr_buffer_remaining(&buffer) == 0;
}
Expand Down

0 comments on commit 7a8b9a4

Please sign in to comment.