From c25d122f129cf6ba5a5d8e0a57bbbc319ab83abd Mon Sep 17 00:00:00 2001 From: TSC21 <n.marques21@hotmail.com> Date: Fri, 30 Nov 2018 08:46:57 +0000 Subject: [PATCH] update micro-CDR version and msg templates to fit the up to date version --- .../microRTPS_client.cpp.template | 21 ++++++++------- msg/templates/uorb_microcdr/msg.cpp.template | 26 +++++++++---------- msg/templates/uorb_microcdr/msg.h.template | 8 +++--- src/modules/micrortps_bridge/micro-CDR | 2 +- .../micrortps_client/microRTPS_client.h | 3 +-- 5 files changed, 29 insertions(+), 31 deletions(-) diff --git a/msg/templates/uorb_microcdr/microRTPS_client.cpp.template b/msg/templates/uorb_microcdr/microRTPS_client.cpp.template index c386f36a8f..974012d445 100644 --- a/msg/templates/uorb_microcdr/microRTPS_client.cpp.template +++ b/msg/templates/uorb_microcdr/microRTPS_client.cpp.template @@ -24,7 +24,8 @@ recv_topics = [s.short_name for idx, s in enumerate(spec) if scope[idx] == MsgSc }@ /**************************************************************************** * - * Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima). + * Copyright (c) 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima). + * Copyright (c) 2018 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -62,7 +63,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 <ucdr/microcdr.h> #include <px4_time.h> #include <uORB/uORB.h> @@ -91,10 +92,10 @@ void* send(void* /*unused*/) orb_set_interval(fds[@(idx)], _options.update_time_ms); @[end for]@ - // MicroBuffer to serialized using the user defined buffer - MicroBuffer MicroBufferWriter; + // ucdrBuffer to serialize using the user defined buffer + ucdrBuffer writer; header_length=transport_node->get_header_length(); - init_micro_buffer(&MicroBufferWriter, (uint8_t*)&data_buffer[header_length], BUFFER_SIZE - header_length); + ucdr_init_buffer(&writer, (uint8_t*)&data_buffer[header_length], BUFFER_SIZE - header_length); struct timespec begin; px4_clock_gettime(CLOCK_REALTIME, &begin); @@ -111,7 +112,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)(&MicroBufferWriter, &data, &data_buffer[header_length], &length); + serialize_@(topic)(&writer, &data, &data_buffer[header_length], &length); if (0 < (read = transport_node->write((char)@(rtps_message_id(ids, topic)), data_buffer, length))) { @@ -165,9 +166,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 - MicroBuffer MicroBufferReader; - init_micro_buffer(&MicroBufferReader, (uint8_t*)data_buffer, BUFFER_SIZE); + // ucdrBuffer to deserialize using the user defined buffer + ucdrBuffer reader; + ucdr_init_buffer(&reader, (uint8_t*)data_buffer, BUFFER_SIZE); @[end if]@ px4_clock_gettime(CLOCK_REALTIME, &begin); @@ -191,7 +192,7 @@ void micrortps_start_topics(struct timespec &begin, int &total_read, uint32_t &r case @(rtps_message_id(ids, topic)): { - deserialize_@(topic)(&MicroBufferReader, &@(topic)_data, data_buffer); + deserialize_@(topic)(&reader, &@(topic)_data, data_buffer); if (!@(topic)_pub) { @(topic)_pub = orb_advertise(ORB_ID(@(topic)), &@(topic)_data); } else { diff --git a/msg/templates/uorb_microcdr/msg.cpp.template b/msg/templates/uorb_microcdr/msg.cpp.template index fa2b38c63e..a08ddcb55e 100644 --- a/msg/templates/uorb_microcdr/msg.cpp.template +++ b/msg/templates/uorb_microcdr/msg.cpp.template @@ -19,7 +19,7 @@ @############################################### /**************************************************************************** * - * Copyright (C) 2013-2016 PX4 Development Team. All rights reserved. + * Copyright (C) 2013-2018 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -62,7 +62,7 @@ topic_name = spec.short_name }@ #include <px4_config.h> -#include <microcdr/microcdr.h> +#include <ucdr/microcdr.h> #include <uORB/topics/@(topic_name).h> #include <uORB_microcdr/topics/@(topic_name).h> @@ -99,9 +99,9 @@ def add_serialize_functions(fields, scope_name): if (not field.is_header): if (field.is_builtin): if (not field.is_array): - print(" serialize_" + str(get_serialization_type_name(field.type)) + "(microCDRWriter, input->" + scope_name+str(field.name) + ");") + print(" ucdr_serialize_" + str(get_serialization_type_name(field.type)) + "(writer, input->" + scope_name+str(field.name) + ");") else: - print(" serialize_array_" + str(get_serialization_type_name(field.base_type)) + "(microCDRWriter, input->" + scope_name+str(field.name) + ", " + str(field.array_len) + ");") + print(" ucdr_serialize_array_" + str(get_serialization_type_name(field.base_type)) + "(writer, input->" + scope_name+str(field.name) + ", " + str(field.array_len) + ");") else: name = field.name children_fields = get_children_fields(field.base_type, search_path) @@ -117,9 +117,9 @@ def add_deserialize_functions(fields, scope_name): if (not field.is_header): if (field.is_builtin): if (not field.is_array): - print(" deserialize_" + str(get_serialization_type_name(field.type)) + "(microCDRReader, &output->" + scope_name+str(field.name) + ");") + print(" ucdr_deserialize_" + str(get_serialization_type_name(field.type)) + "(reader, &output->" + scope_name+str(field.name) + ");") else: - print(" deserialize_array_" + str(get_serialization_type_name(field.base_type)) + "(microCDRReader, output->" + scope_name+str(field.name) + ", " + str(field.array_len) + ");") + print(" ucdr_deserialize_array_" + str(get_serialization_type_name(field.base_type)) + "(reader, output->" + scope_name+str(field.name) + ", " + str(field.array_len) + ");") else: name = field.name children_fields = get_children_fields(field.base_type, search_path) @@ -141,23 +141,23 @@ def add_code_to_deserialize(): add_deserialize_functions(sorted_fields, "") }@ -void serialize_@(topic_name)(MicroBuffer *microCDRWriter, const struct @(uorb_struct) *input, char *output, uint32_t *length) +void serialize_@(topic_name)(ucdrBuffer *writer, const struct @(uorb_struct) *input, char *output, uint32_t *length) { - if (nullptr == microCDRWriter || nullptr == input || nullptr == output || nullptr == length) + if (nullptr == writer || nullptr == input || nullptr == output || nullptr == length) return; - reset_micro_buffer(microCDRWriter); + ucdr_reset_buffer(writer); @add_code_to_serialize() - (*length) = micro_buffer_length(microCDRWriter); + (*length) = ucdr_buffer_length(writer); } -void deserialize_@(topic_name)(MicroBuffer *microCDRReader, struct @(uorb_struct) *output, const char *input) +void deserialize_@(topic_name)(ucdrBuffer *reader, struct @(uorb_struct) *output, const char *input) { - if (nullptr == microCDRReader || nullptr == output || nullptr == input) + if (nullptr == reader || nullptr == output || nullptr == input) return; - reset_micro_buffer(microCDRReader); + ucdr_reset_buffer(reader); @add_code_to_deserialize() } diff --git a/msg/templates/uorb_microcdr/msg.h.template b/msg/templates/uorb_microcdr/msg.h.template index ad402fb609..eb3bbd9664 100644 --- a/msg/templates/uorb_microcdr/msg.h.template +++ b/msg/templates/uorb_microcdr/msg.h.template @@ -19,7 +19,7 @@ @############################################### /**************************************************************************** * - * Copyright (C) 2013-2016 PX4 Development Team. All rights reserved. + * Copyright (C) 2013-2018 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -69,7 +69,5 @@ topic_name = spec.short_name #include <uORB/topics/@(topic_name).h> #include <uORB_microcdr/topics/@(topic_name).h> -struct MicroBuffer; - -void serialize_@(topic_name)(MicroBuffer *microCDRWriter, const struct @(uorb_struct) *input, char *output, uint32_t *length); -void deserialize_@(topic_name)(MicroBuffer *microCDRReader, struct @(uorb_struct) *output, const char *input); +void serialize_@(topic_name)(ucdrBuffer *writer, const struct @(uorb_struct) *input, char *output, uint32_t *length); +void deserialize_@(topic_name)(ucdrBuffer *reader, struct @(uorb_struct) *output, const char *input); diff --git a/src/modules/micrortps_bridge/micro-CDR b/src/modules/micrortps_bridge/micro-CDR index f325c4f773..d23eda8772 160000 --- a/src/modules/micrortps_bridge/micro-CDR +++ b/src/modules/micrortps_bridge/micro-CDR @@ -1 +1 @@ -Subproject commit f325c4f7731a5d10c474e1a30f7407c220d97b54 +Subproject commit d23eda8772ecf846531ee470a81fb1be37802e7b diff --git a/src/modules/micrortps_bridge/micrortps_client/microRTPS_client.h b/src/modules/micrortps_bridge/micrortps_client/microRTPS_client.h index c036343b8c..e256fd10c5 100644 --- a/src/modules/micrortps_bridge/micrortps_client/microRTPS_client.h +++ b/src/modules/micrortps_bridge/micrortps_client/microRTPS_client.h @@ -40,7 +40,7 @@ #include <pthread.h> #include <termios.h> -#include <microcdr/microcdr.h> +#include <ucdr/microcdr.h> #include <px4_config.h> #include <px4_getopt.h> #include <px4_posix.h> @@ -92,4 +92,3 @@ struct options { extern struct options _options; extern bool _should_exit_task; extern Transport_node *transport_node; - -- GitLab