mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 09:22:18 +00:00
Update micro-CDR to latest and fix API usage (#9651)
* uorb_microcdr: msg.cpp.template: update API for how the buffer length is obtained * micrortps_bridge: CMakeLists: temporarily deactivate check endianness option
This commit is contained in:
committed by
Daniel Agar
parent
72de9a901d
commit
83fd5a5fd1
@@ -61,7 +61,7 @@ recv_topics = [s.short_name for idx, s in enumerate(spec) if scope[idx] == MsgSc
|
||||
#include <ctime>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <microcdr/microCdr.h>
|
||||
#include <microcdr/microcdr.h>
|
||||
#include <px4_time.h>
|
||||
#include <uORB/uORB.h>
|
||||
|
||||
@@ -90,13 +90,10 @@ void* send(void* /*unused*/)
|
||||
orb_set_interval(fds[@(idx)], _options.update_time_ms);
|
||||
@[end for]@
|
||||
|
||||
// microBuffer to serialized using the user defined buffer
|
||||
struct microBuffer microBufferWriter;
|
||||
// MicroBuffer to serialized using the user defined buffer
|
||||
MicroBuffer MicroBufferWriter;
|
||||
header_length=transport_node->get_header_length();
|
||||
initStaticAlignedBuffer(&data_buffer[header_length], BUFFER_SIZE-header_length, µBufferWriter);
|
||||
// microCDR structs for managing the microBuffer
|
||||
struct microCDR microCDRWriter;
|
||||
initMicroCDR(µCDRWriter, µBufferWriter);
|
||||
init_micro_buffer(&MicroBufferWriter, (uint8_t*)&data_buffer[header_length], BUFFER_SIZE - header_length);
|
||||
|
||||
struct timespec begin;
|
||||
px4_clock_gettime(CLOCK_REALTIME, &begin);
|
||||
@@ -113,7 +110,7 @@ void* send(void* /*unused*/)
|
||||
// copy raw data into local buffer
|
||||
if (orb_copy(ORB_ID(@(topic)), fds[@(idx)], &data) == 0) {
|
||||
/* payload is shifted by header length to make room for header*/
|
||||
serialize_@(topic)(&data, &data_buffer[header_length], &length, µCDRWriter);
|
||||
serialize_@(topic)(&MicroBufferWriter, &data, &data_buffer[header_length], &length);
|
||||
|
||||
if (0 < (read = transport_node->write((char)@(message_id(topic)), data_buffer, length)))
|
||||
{
|
||||
@@ -167,12 +164,9 @@ void micrortps_start_topics(struct timespec &begin, int &total_read, uint32_t &r
|
||||
orb_advert_t @(topic)_pub = nullptr;
|
||||
@[end for]@
|
||||
|
||||
// microBuffer to deserialized using the user defined buffer
|
||||
struct microBuffer microBufferReader;
|
||||
initDeserializedAlignedBuffer(data_buffer, BUFFER_SIZE, µBufferReader);
|
||||
// microCDR structs for managing the microBuffer
|
||||
struct microCDR microCDRReader;
|
||||
initMicroCDR(µCDRReader, µBufferReader);
|
||||
// MicroBuffer to deserialized using the user defined buffer
|
||||
MicroBuffer MicroBufferReader;
|
||||
init_micro_buffer(&MicroBufferReader, (uint8_t*)data_buffer, BUFFER_SIZE);
|
||||
@[end if]@
|
||||
|
||||
px4_clock_gettime(CLOCK_REALTIME, &begin);
|
||||
@@ -195,7 +189,7 @@ void micrortps_start_topics(struct timespec &begin, int &total_read, uint32_t &r
|
||||
@[for topic in recv_topics]@
|
||||
case @(message_id(topic)):
|
||||
{
|
||||
deserialize_@(topic)(&@(topic)_data, data_buffer, µCDRReader);
|
||||
deserialize_@(topic)(&MicroBufferReader, &@(topic)_data, data_buffer);
|
||||
if (!@(topic)_pub) {
|
||||
@(topic)_pub = orb_advertise(ORB_ID(@(topic)), &@(topic)_data);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user