Dependents:   mbed-os-example-mros2 example-mbed-mros2-sub-pose example-mbed-mros2-pub-twist example-mbed-mros2-mturtle-teleop

Committer:
smoritaemb
Date:
Sat Mar 19 09:23:37 2022 +0900
Revision:
7:c80f65422d99
Parent:
0:580aba13d1a1
Merge test_assortment_of_msgs branch.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
smoritaemb 0:580aba13d1a1 1 // Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima).
smoritaemb 0:580aba13d1a1 2 //
smoritaemb 0:580aba13d1a1 3 // Licensed under the Apache License, Version 2.0 (the "License");
smoritaemb 0:580aba13d1a1 4 // you may not use this file except in compliance with the License.
smoritaemb 0:580aba13d1a1 5 // You may obtain a copy of the License at
smoritaemb 0:580aba13d1a1 6 //
smoritaemb 0:580aba13d1a1 7 // http://www.apache.org/licenses/LICENSE-2.0
smoritaemb 0:580aba13d1a1 8 //
smoritaemb 0:580aba13d1a1 9 // Unless required by applicable law or agreed to in writing, software
smoritaemb 0:580aba13d1a1 10 // distributed under the License is distributed on an "AS IS" BASIS,
smoritaemb 0:580aba13d1a1 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
smoritaemb 0:580aba13d1a1 12 // See the License for the specific language governing permissions and
smoritaemb 0:580aba13d1a1 13 // limitations under the License.
smoritaemb 0:580aba13d1a1 14
smoritaemb 0:580aba13d1a1 15 #ifndef _MICROCDR_COMMON_H_
smoritaemb 0:580aba13d1a1 16 #define _MICROCDR_COMMON_H_
smoritaemb 0:580aba13d1a1 17
smoritaemb 0:580aba13d1a1 18 #ifdef __cplusplus
smoritaemb 0:580aba13d1a1 19 extern "C" {
smoritaemb 0:580aba13d1a1 20 #endif
smoritaemb 0:580aba13d1a1 21
smoritaemb 0:580aba13d1a1 22 #include <ucdr/dll.h>
smoritaemb 0:580aba13d1a1 23 #include <ucdr/config.h>
smoritaemb 0:580aba13d1a1 24
smoritaemb 0:580aba13d1a1 25 #include <stdint.h>
smoritaemb 0:580aba13d1a1 26 #include <stdbool.h>
smoritaemb 0:580aba13d1a1 27 #include <stddef.h>
smoritaemb 0:580aba13d1a1 28
smoritaemb 0:580aba13d1a1 29 typedef enum ucdrEndianness {
smoritaemb 0:580aba13d1a1 30 UCDR_BIG_ENDIANNESS,
smoritaemb 0:580aba13d1a1 31 UCDR_LITTLE_ENDIANNESS
smoritaemb 0:580aba13d1a1 32
smoritaemb 0:580aba13d1a1 33 } ucdrEndianness;
smoritaemb 0:580aba13d1a1 34
smoritaemb 0:580aba13d1a1 35 typedef struct ucdrBuffer
smoritaemb 0:580aba13d1a1 36 {
smoritaemb 0:580aba13d1a1 37 const uint8_t *init;
smoritaemb 0:580aba13d1a1 38 const uint8_t *final;
smoritaemb 0:580aba13d1a1 39 uint8_t *iterator;
smoritaemb 0:580aba13d1a1 40
smoritaemb 0:580aba13d1a1 41 ucdrEndianness endianness;
smoritaemb 0:580aba13d1a1 42 uint32_t last_data_size;
smoritaemb 0:580aba13d1a1 43
smoritaemb 0:580aba13d1a1 44 bool error;
smoritaemb 0:580aba13d1a1 45
smoritaemb 0:580aba13d1a1 46 } ucdrBuffer;
smoritaemb 0:580aba13d1a1 47
smoritaemb 0:580aba13d1a1 48 UCDRDLLAPI extern const ucdrEndianness UCDR_MACHINE_ENDIANNESS;
smoritaemb 0:580aba13d1a1 49
smoritaemb 0:580aba13d1a1 50 // ------------------------------------------------
smoritaemb 0:580aba13d1a1 51 // Main library functions
smoritaemb 0:580aba13d1a1 52 // ------------------------------------------------
smoritaemb 0:580aba13d1a1 53 UCDRDLLAPI void ucdr_init_buffer (ucdrBuffer* mb, const uint8_t* data, const uint32_t size);
smoritaemb 0:580aba13d1a1 54 UCDRDLLAPI void ucdr_init_buffer_offset (ucdrBuffer* mb, const uint8_t* data, const uint32_t size, uint32_t offset);
smoritaemb 0:580aba13d1a1 55 UCDRDLLAPI void ucdr_init_buffer_offset_endian (ucdrBuffer* mb, const uint8_t* data, const uint32_t size, uint32_t offset, ucdrEndianness endianness);
smoritaemb 0:580aba13d1a1 56 UCDRDLLAPI void ucdr_copy_buffer (ucdrBuffer* mb_dest, const ucdrBuffer* mb_source);
smoritaemb 0:580aba13d1a1 57 bool ucdr_check_buffer(ucdrBuffer* mb, const uint32_t bytes);
smoritaemb 0:580aba13d1a1 58
smoritaemb 0:580aba13d1a1 59 UCDRDLLAPI void ucdr_reset_buffer (ucdrBuffer* mb);
smoritaemb 0:580aba13d1a1 60 UCDRDLLAPI void ucdr_reset_buffer_offset (ucdrBuffer* mb, const uint32_t offset);
smoritaemb 0:580aba13d1a1 61
smoritaemb 0:580aba13d1a1 62 UCDRDLLAPI void ucdr_align_to (ucdrBuffer* mb, const uint32_t alignment);
smoritaemb 0:580aba13d1a1 63 UCDRDLLAPI uint32_t ucdr_alignment (uint32_t buffer_position, const uint32_t data_size);
smoritaemb 0:580aba13d1a1 64 UCDRDLLAPI uint32_t ucdr_buffer_alignment(const ucdrBuffer* mb, const uint32_t data_size);
smoritaemb 0:580aba13d1a1 65
smoritaemb 0:580aba13d1a1 66 UCDRDLLAPI size_t ucdr_buffer_size (const ucdrBuffer* mb);
smoritaemb 0:580aba13d1a1 67 UCDRDLLAPI size_t ucdr_buffer_length (const ucdrBuffer* mb);
smoritaemb 0:580aba13d1a1 68 UCDRDLLAPI size_t ucdr_buffer_remaining (const ucdrBuffer* mb);
smoritaemb 0:580aba13d1a1 69 UCDRDLLAPI ucdrEndianness ucdr_buffer_endianness(const ucdrBuffer* mb);
smoritaemb 0:580aba13d1a1 70 UCDRDLLAPI bool ucdr_buffer_has_error (const ucdrBuffer* mb);
smoritaemb 0:580aba13d1a1 71
smoritaemb 0:580aba13d1a1 72 #ifdef __cplusplus
smoritaemb 0:580aba13d1a1 73 }
smoritaemb 0:580aba13d1a1 74 #endif
smoritaemb 0:580aba13d1a1 75
smoritaemb 0:580aba13d1a1 76 #endif //_MICROCDR_COMMON_H_