# eProsima Micro CDR
[![Releases](https://img.shields.io/github/release/eProsima/Micro-CDR.svg)](https://github.com/eProsima/Micro-CDR/releases)
[![License](https://img.shields.io/github/license/eProsima/Micro-CDR.svg)](https://github.com/eProsima/Micro-CDR/blob/master/LICENSE)
[![Issues](https://img.shields.io/github/issues/eProsima/Micro-CDR.svg)](https://github.com/eProsima/Micro-CDR/issues)
[![Forks](https://img.shields.io/github/forks/eProsima/Micro-CDR.svg)](https://github.com/eProsima/Micro-CDR/network/members)
[![Stars](https://img.shields.io/github/stars/eProsima/Micro-CDR.svg)](https://github.com/eProsima/Micro-CDR/stargazers)
<a href="http://www.eprosima.com"><img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcSd0PDlVz1U_7MgdTe0FRIWD0Jc9_YH-gGi0ZpLkr-qgCI6ZEoJZ5GBqQ" align="left" hspace="8" vspace="2" width="100" height="100" ></a>
*eProsima MicroCDR* is a *C* library implementing the *CDR* standard serialization methods.
This library is focused on embedded and resource-limited systems.
*MicroCDR* uses a static buffer, and allow to serialize and deserialize in both, big endianness and little endianness.
## Usage examples
This is a code example showing the serialization and deserialization of a string.
As *MicroCDR* uses a static buffer, that means the user has to provide a defined buffer and its size during the *ucdrBuffer* creation.
```c
#include <ucdr/microcdr.h>
#include <stdio.h>
#define BUFFER_LENGTH 256
int main(int argc, char** args)
{
// Data buffer
uint8_t buffer[BUFFER_LENGTH];
// Structs for handle the buffer.
ucdrBuffer writer;
ucdrBuffer reader;
// Initialize the MicroBuffers for working with an user-managed buffer.
ucdr_init_buffer(&writer, buffer, BUFFER_LENGTH);
ucdr_init_buffer(&reader, buffer, BUFFER_LENGTH);
// Serialize data
char input[16] = "Hello MicroCDR!"; //16 characters
ucdr_serialize_array_char(&writer, input, 16);
// Deserialize data
char output[16];
ucdr_deserialize_array_char(&reader, output, 16);
printf("Input: %s\n", input);
printf("Output: %s\n", output);
return 0;
}
```
## API functions
```c
void ucdr_init_buffer (ucdrBuffer* mb, uint8_t* data, const uint32_t size);
void ucdr_init_buffer_offset (ucdrBuffer* mb, uint8_t* data, const uint32_t size, uint32_t offset);
```
Initialize a `ucdrBuffer` structure, the main struct of *MicroCDR*.
- `mb`: the `ucdrBuffer` struct
- `data`: the buffer that the `ucdrBuffer` will use.
- `size`: the size of the buffer that the `ucdrBuffer` will use.
- `offset`: where the serialization/deserialization will start.
Initially, the serialization/deserialization starts at the beginning of the buffer.
---
```c
void ucdr_copy_buffer (ucdrBuffer* mb_dest, const ucdrBuffer* mb_source);
```
Copy a `ucdrBuffer` structure data to another `ucdrBuffer` structure.
- `mb_dest`: the destination `ucdrBuffer` struct.
- `mb_source`: the origin initialized `ucdrBuffer` struct.
---
```c
void ucdr_reset_buffer (ucdrBuffer* mb);
void ucdr_reset_buffer_offset(ucdrBuffer* mb, const uint32_t offset);
```
Reset the `ucdrBuffer` as the same state that it was created.
- `mb`: the `ucdrBuffer` struct.
- `offset`: where the serialization/deserialization will start.
Initially, the serialization/deserialization starts at the beginning of the buffer.
---
```c
void ucdr_align_to (ucdrBuffer* mb, const uint32_t alignment);
```
Align the ucdrBuffer to an `alignment` position.
After call this function, the serialization pointer will be moved only if the current `ucdrBuffer` was not aligment to the passed value.
- `mb`: the `ucdrBuffer` struct
- `alignment`: the alignment value used.
---
```c
uint32_t ucdr_aligment(uint32_t buffer_position, const uint32_t data_size);
```
Returns the aligment necessary to serialize/deserialize a type with `data_size` size.
- `buffer_position`: the current serialization/deserialization position of the `ucdrBuffer`. (Typically `mb->iterator - mb->init`).
- `data_size`: the bytes of the data that you are asking for.
---
```c
uint32_t ucdr_buffer_alignment(const ucdrBuffer* mb, const uint32_t data_size);
```
Returns the aligment necessary to serialize/deserialize a type with `data_size` size into the `ucdrBuffer` given.
- `mb`: the `ucdrBuffer` struct to ask the alignment.
- `data_size`: the bytes of the data that you are asking for.
---
```c
size_t ucdr_buffer_size(const ucdrBuffer* mb);
```
Returns the memory size of the buffer.
- `mb`: the `ucdrBuffer` struct
---
```c
size_t ucdr_buffer_length(const ucdrBuffer* mb);
```
Returns the size of the serialized/deserialized data.
- `mb`: the `ucdrBuffer` struct
---
```c
size_t ucdr_buffer_remaining(const ucdrBuffer* mb);
```
Returns the remaining size for the serializing/deserializing.
- `mb`: the `ucdrBuffer` struct
---
```c
ucdrEndianness ucdr_buffer_endianness(const ucdrBuffer* mb);
```
Returns the serialization/deserialization endianness.
- `mb`: the `ucdrBuffer` struct
---
```c
bool ucdr_buffer_error(const ucdrBuffer* mb);
```
Returns the status error of the `ucdrBuffer`.
- `mb`: the `ucdrBuffer` struct
### Serialization/deserialization functions
Adding to this, there is a big set of functions for deserialize and deserialize different kind of types:
- Basics: `bool`, `char`, `int8_t`, `uint8_t`,`int16_t`, `uint16_t`,`int32_t`, `uint32_t`,`int64_t`, `uint64_t`,`float`, `double`.
- Arrays: Any fixed size of basics types.
- Sequence: Similar to arrays, but the information about the size is serialized along with the data.
### Endianness
*MicroCDR* supports little and big endianness.
The **machine endianness** can be set by the cmake variable: `CONFIG_BIG_ENDIANNESS`.
By default, if this varible is `OFF` which means that the machine endianness is little endianness.
The `ucdrBuffer` endianness can be set by the `endianness` parameter of the structure to `UCDR_BIG_ENDIANNESS` or `UCDR_LITTLE_ENDIANNESS`.
Also, there are a functions that allow to force an endianness independiently of the `ucdrBuffer` endianness in their serialization/deserialization.
These functions contains the name `endianness` in their signature.
### Error
All serialization/deserialization functions return a boolean indicating the result of their operations.
When a serialization/deserialization could not be possible (the type can not be serialized, or the capacity of the destination buffer is not enough),
an status error is setted into the `ucdrBuffer`.
If a `ucdrBuffer` has an error state, the next serialization/deserialization operations will not works and will return `false` in their execution.
A buffer marked with an error can be used, but any serialization/deserialization operation over it will not produce any effect.
If is kwown that an operation can fails over a `ucdrBuffer`, and its necessary to continue with the serialization/deserialization if it happens,
the `ucdrBuffer` state can be saved using the `ucdr_copy_buffer` function.
After the application of the wrong serialization/deserialization, only the `ucdrBuffer` that performed the operation will have a dirty state.
## Serialization/deserialization list
The available modes of serialization/deserializations in *MicroCDR* are shown in the following table.
| Type | Endianness |
| -------------------- | ---------- |
| bool | |
| char | |
| int8 | |
| uint8 | |
| int16 | |
| int16 | endianness |
| uint16 | |
| uint16 | endianness |
| int32 | |
| int32 | endianness |
| uint32 | |
| uint32 | endianness |
| int64 | |
| int64 | endianness |
| uint64 |
没有合适的资源?快使用搜索试试~ 我知道了~
用于嵌入式设备的 RTPS/DDS 协议的可移植实现_C++_代码_相关文件_下载
共96个文件
h:58个
cpp:13个
c:6个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 3 下载量 105 浏览量
2022-07-07
23:37:03
上传
评论 7
收藏 381KB ZIP 举报
温馨提示
嵌入式RTPS 该存储库包含 EmbeddedRTPS 的源代码,嵌入式系统的实时发布订阅协议 (RTPS) 的可移植和开源 C++ 实现。RTPS 基于发布-订阅机制,是数据分发服务 (DDS) 的核心。DDS 用于机器人操作系统 2 (ROS2) 中的许多其他应用程序,也是 AUTOSAR 自适应平台的一部分。EmbeddedRTPS 允许将具有以太网功能的微控制器作为一流的参与者集成到基于 DDS 的系统中。 EmbeddedRTPS 是可移植的,因为它只使用可用于大量嵌入式系统的轻量级 IP 和 FreeRTOS API。一旦构建了可能的端点,嵌入式RTPS 就避免了动态内存分配。请注意,embeddedRTPS 仅实施基本的服务质量 (QoS) 策略,远非完整的 RTPS 实施。 特征 Discovery实现了简单参与者发现协议 (SPDP) 以及简单端点发现协议 (SEDP)。 互操作性我们已经成功测试了与FastDDS 2.3.1的互操作性 QoS 策略实现了可靠和尽力而为的端点。 更多详情、使用方法,请下载后阅读README.md文件
资源推荐
资源详情
资源评论
收起资源包目录
embeddedRTPS-master.zip (96个子文件)
embeddedRTPS-master
.gitmodules 114B
media
performance_rtt.png 238KB
include
rtps
communication
TcpipCoreLock.h 1KB
PacketInfo.h 2KB
UdpDriver.h 2KB
UdpConnection.h 2KB
config_aurix.h 3KB
discovery
SPDPAgent.h 3KB
BuiltInEndpoints.h 2KB
ParticipantProxyData.h 7KB
TopicData.h 3KB
SEDPAgent.h 4KB
messages
MessageTypes.h 13KB
MessageFactory.h 6KB
MessageReceiver.h 3KB
config_stm.h 3KB
ThreadPool.h 3KB
common
types.h 8KB
Locator.h 6KB
config_desktop.h 4KB
rtps.h 1KB
utils
hash.h 1KB
Log.h 2KB
sysFunctions.h 2KB
printutils.h 590B
constants.h 1KB
udpUtils.h 4KB
Lock.h 1KB
entities
Reader.h 4KB
StatefulReader.h 2KB
StatefulWriter.tpp 14KB
Domain.h 3KB
StatefulReader.tpp 6KB
ReaderProxy.h 2KB
StatelessWriter.tpp 10KB
StatelessReader.h 2KB
WriterProxy.h 2KB
Participant.h 4KB
StatelessWriter.h 3KB
Writer.h 2KB
StatefulWriter.h 3KB
config_r5.h 3KB
storages
CacheChange.h 2KB
MemoryPool.h 5KB
ThreadSafeCircularBuffer.h 2KB
ThreadSafeCircularBuffer.tpp 3KB
SimpleHistoryCache.h 5KB
PBufWrapper.h 3KB
ci
clang-check-format.sh 495B
Readme.md 5KB
LICENSE 1KB
src
communication
UdpDriver.cpp 4KB
ThreadPool.cpp 6KB
discovery
ParticipantProxyData.cpp 7KB
TopicData.cpp 8KB
SPDPAgent.cpp 13KB
SEDPAgent.cpp 11KB
messages
MessageTypes.cpp 7KB
MessageReceiver.cpp 7KB
rtps.cpp 4KB
entities
Participant.cpp 11KB
StatelessReader.cpp 4KB
Domain.cpp 16KB
storages
PBufWrapper.cpp 5KB
thirdparty
lwip
lwipopts.h 12KB
default_netif.c 3KB
default_netif.h 2KB
lwipcfg_unix.h 3KB
lwipcfg_r5.h 3KB
Micro-CDR
cmake
config
microcdrConfig.cmake 2KB
packaging
Config.cmake.in 1KB
common
eprosima_libraries.cmake 4KB
check_configuration.cmake 5KB
gtest.cmake 5KB
include
ucdr
config.h 956B
common.h 3KB
config.h.in 1KB
dll.h 1006B
microcdr.h 944B
types
array.h 6KB
sequence.h 7KB
string.h 1KB
basic.h 4KB
LICENSE 11KB
src
c
common.c 4KB
common_internals.h 1KB
types
array_internals.h 2KB
array.c 14KB
string.c 2KB
sequence.c 14KB
sequence_internals.h 2KB
basic_internals.h 2KB
basic.c 13KB
CMakeLists.txt 7KB
README.md 10KB
.gitignore 123B
共 96 条
- 1
资源评论
- MappingNode2023-01-04感谢大佬,让我及时解决了当下的问题,解燃眉之急,必须支持!
- hx121711712024-02-15资源很受用,资源主总结的很全面,内容与描述一致,解决了我当下的问题。
- cherry19822023-05-11资源内容详实,描述详尽,解决了我的问题,受益匪浅,学到了。
快撑死的鱼
- 粉丝: 1w+
- 资源: 9156
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- mybatis中的动态sql, 涉及 where trim set if foreach等
- 简单- 快递运输(Java & JS & Python & C).html
- mybatis框架 更改ems系统,使用动态sql等.zip
- 易语言工具条下拉菜单实现
- Mybatis动态SQL高级映射.zip
- 源码esp8266开发板机智云机智云智能灯
- Python实现多图像转换成连贯的PDF文件,支持所有图片格式,可预览、裁剪、自定义PDF布局、设置图像顺序、PDF质量选择等
- H5腾讯地图选择位置组件
- 基于UCC28019+LM5017电源板硬件(原理图+PCB)工程文件.zip
- 源码esp8266开发板机智云机智云空气净化器
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功