Send RTPS header and payload in one stream

This avoids assembling the header and payload on the receiver side
This commit is contained in:
ritul jasuja
2018-01-24 19:18:54 +05:30
committed by Beat Küng
parent 2517d3854c
commit 13a3791c47
4 changed files with 24 additions and 15 deletions
@@ -193,12 +193,14 @@ void t_send(void *data)
// Send subscribed topics over UART
while (topics.hasMsg(&topic_ID))
{
eprosima::fastcdr::FastBuffer cdrbuffer(data_buffer, sizeof(data_buffer));
uint16_t header_length = get_header_length();
/* make room for the header to fill in later */
eprosima::fastcdr::FastBuffer cdrbuffer(&data_buffer[header_length], sizeof(data_buffer)-header_length);
eprosima::fastcdr::Cdr scdr(cdrbuffer);
if (topics.getMsg(topic_ID, scdr))
{
length = scdr.getSerializedDataLength();
if (0 < (length = transport_node->write(topic_ID, scdr.getBufferPointer(), length)))
if (0 < (length = transport_node->write(topic_ID, data_buffer, length)))
{
total_sent += length;
++sent;