File syn_xrce_dds.h¶
FileList > proto > syn_xrce_dds.h
Go to the source code of this file
Micro-ROS & eProsima Micro XRCE-DDS v1.2 Protocol Client Engine. More...
#include "../common/syn_defs.h"#include "../net/syn_transport.h"#include "../pt/syn_pt.h"#include "../sched/syn_sched.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_CDR_Reader CDR deserialization input buffer context. |
| struct | SYN_CDR_Writer CDR serialization output buffer context. |
| struct | SYN_XRCE_Client Micro XRCE-DDS Client instance context. |
| struct | SYN_XRCE_Config Micro XRCE-DDS Client configuration. |
| struct | SYN_XRCE_Object Registered XRCE entity tracking record. |
Public Types¶
| Type | Name |
|---|---|
| enum | SYN_XRCE_ClientState XRCE client connection state. |
| typedef void(* | SYN_XRCE_DataCb Callback for incoming topic data from an agent DataReader. |
| typedef void(* | SYN_XRCE_StatusCb Callback for status notifications (entity creation, ack, etc). |
Public Functions¶
| Type | Name |
|---|---|
| bool | syn_cdr_read_bool (SYN_CDR_Reader * r, bool * out) Read boolean. |
| bool | syn_cdr_read_bytes (SYN_CDR_Reader * r, uint8_t * out_buf, size_t len) Read raw byte buffer without alignment padding. |
| bool | syn_cdr_read_double (SYN_CDR_Reader * r, double * out) Read 64-bit double (8-byte aligned). |
| bool | syn_cdr_read_float (SYN_CDR_Reader * r, float * out) Read 32-bit float (4-byte aligned). |
| bool | syn_cdr_read_i16 (SYN_CDR_Reader * r, int16_t * out) Read signed 16-bit integer (2-byte aligned). |
| bool | syn_cdr_read_i32 (SYN_CDR_Reader * r, int32_t * out) Read signed 32-bit integer (4-byte aligned). |
| bool | syn_cdr_read_i64 (SYN_CDR_Reader * r, int64_t * out) Read signed 64-bit integer (8-byte aligned). |
| bool | syn_cdr_read_i8 (SYN_CDR_Reader * r, int8_t * out) Read signed 8-bit integer. |
| bool | syn_cdr_read_string (SYN_CDR_Reader * r, char * out_buf, size_t max_len) Read null-terminated string with length prefix. |
| bool | syn_cdr_read_u16 (SYN_CDR_Reader * r, uint16_t * out) Read unsigned 16-bit integer (2-byte aligned). |
| bool | syn_cdr_read_u32 (SYN_CDR_Reader * r, uint32_t * out) Read unsigned 32-bit integer (4-byte aligned). |
| bool | syn_cdr_read_u64 (SYN_CDR_Reader * r, uint64_t * out) Read unsigned 64-bit integer (8-byte aligned). |
| bool | syn_cdr_read_u8 (SYN_CDR_Reader * r, uint8_t * out) Read unsigned 8-bit integer. |
| void | syn_cdr_reader_init (SYN_CDR_Reader * r, const uint8_t * buf, size_t size) Initialize CDR reader. |
| bool | syn_cdr_write_bool (SYN_CDR_Writer * w, bool v) Write boolean. |
| bool | syn_cdr_write_bytes (SYN_CDR_Writer * w, const uint8_t * bytes, size_t len) Write raw byte buffer without alignment padding. |
| bool | syn_cdr_write_double (SYN_CDR_Writer * w, double v) Write 64-bit double (8-byte aligned). |
| bool | syn_cdr_write_float (SYN_CDR_Writer * w, float v) Write 32-bit float (4-byte aligned). |
| bool | syn_cdr_write_i16 (SYN_CDR_Writer * w, int16_t v) Write signed 16-bit integer (2-byte aligned). |
| bool | syn_cdr_write_i32 (SYN_CDR_Writer * w, int32_t v) Write signed 32-bit integer (4-byte aligned). |
| bool | syn_cdr_write_i64 (SYN_CDR_Writer * w, int64_t v) Write signed 64-bit integer (8-byte aligned). |
| bool | syn_cdr_write_i8 (SYN_CDR_Writer * w, int8_t v) Write signed 8-bit integer. |
| bool | syn_cdr_write_string (SYN_CDR_Writer * w, const char * str) Write null-terminated string with 32-bit length prefix and null terminator. |
| bool | syn_cdr_write_u16 (SYN_CDR_Writer * w, uint16_t v) Write unsigned 16-bit integer (2-byte aligned). |
| bool | syn_cdr_write_u32 (SYN_CDR_Writer * w, uint32_t v) Write unsigned 32-bit integer (4-byte aligned). |
| bool | syn_cdr_write_u64 (SYN_CDR_Writer * w, uint64_t v) Write unsigned 64-bit integer (8-byte aligned). |
| bool | syn_cdr_write_u8 (SYN_CDR_Writer * w, uint8_t v) Write unsigned 8-bit integer. |
| void | syn_cdr_writer_init (SYN_CDR_Writer * w, uint8_t * buf, size_t size) Initialize CDR writer. |
| SYN_Status | syn_xrce_client_create_datareader (SYN_XRCE_Client * client, uint16_t reader_id, uint16_t subscriber_id, uint16_t topic_id) Create a DDS DataReader entity. |
| SYN_Status | syn_xrce_client_create_datawriter (SYN_XRCE_Client * client, uint16_t writer_id, uint16_t publisher_id, uint16_t topic_id) Create a DDS DataWriter entity. |
| SYN_Status | syn_xrce_client_create_participant (SYN_XRCE_Client * client, uint16_t participant_id) Create a DDS DomainParticipant entity. |
| SYN_Status | syn_xrce_client_create_publisher (SYN_XRCE_Client * client, uint16_t publisher_id, uint16_t participant_id) Create a DDS Publisher entity. |
| SYN_Status | syn_xrce_client_create_session (SYN_XRCE_Client * client) Connect and establish session with Micro-ROS Agent. |
| SYN_Status | syn_xrce_client_create_subscriber (SYN_XRCE_Client * client, uint16_t subscriber_id, uint16_t participant_id) Create a DDS Subscriber entity. |
| SYN_Status | syn_xrce_client_create_topic (SYN_XRCE_Client * client, uint16_t topic_id, uint16_t participant_id, const char * topic_name, const char * type_name) Create a DDS Topic entity. |
| SYN_Status | syn_xrce_client_init (SYN_XRCE_Client * client, const SYN_XRCE_Config * cfg) Initialize Micro XRCE-DDS Client. |
| SYN_PT_Status | syn_xrce_client_pt (SYN_PT * pt, SYN_Task * task) Protothread continuation function for syn_sched . |
| SYN_Status | syn_xrce_client_read_data (SYN_XRCE_Client * client, uint16_t reader_id) Request incoming topic samples from an active DataReader. |
| SYN_Status | syn_xrce_client_step (SYN_XRCE_Client * client, uint32_t now_ms) Advance the XRCE-DDS client state machine by one step / tick. |
| SYN_Status | syn_xrce_client_write_data (SYN_XRCE_Client * client, uint16_t writer_id, const uint8_t * data, size_t len) Publish CDR serialized data payload to a DataWriter. |
Macros¶
Detailed Description¶
Implements a zero-heap, deterministic Micro XRCE-DDS client for ROS 2:
* Common Data Representation (CDR) serializer and deserializer with strict alignment.
* XRCE-DDS submessage framing (CREATE_CLIENT, CREATE, WRITE_DATA, READ_DATA, DATA, STATUS).
* Full ROS 2 entity tree management (Participant, Topic, Publisher, Subscriber, DataWriter, DataReader).
* Non-blocking poll ticks and cooperative protothread continuation for syn_sched.
Public Types Documentation¶
enum SYN_XRCE_ClientState¶
XRCE client connection state.
enum SYN_XRCE_ClientState {
SYN_XRCE_STATE_DISCONNECTED = 0,
SYN_XRCE_STATE_CONNECTING,
SYN_XRCE_STATE_CONNECTED,
SYN_XRCE_STATE_ERROR
};
typedef SYN_XRCE_DataCb¶
Callback for incoming topic data from an agent DataReader.
typedef void(* SYN_XRCE_DataCb) (uint16_t reader_id, const uint8_t *payload, size_t len, void *user_data);
Parameters:
reader_idDataReader object ID.payloadCDR serialized topic payload.lenPayload length in bytes.user_dataUser context pointer.
typedef SYN_XRCE_StatusCb¶
Callback for status notifications (entity creation, ack, etc).
Parameters:
req_idRequest ID matching the command.statusXRCE status code (SYN_XRCE_STATUS_OK, etc).user_dataUser context pointer.
Public Functions Documentation¶
function syn_cdr_read_bool¶
Read boolean.
Parameters:
rReader context.outOutput pointer.
Returns:
true on success, false on underflow.
function syn_cdr_read_bytes¶
Read raw byte buffer without alignment padding.
Parameters:
rReader context.out_bufOutput buffer.lenNumber of bytes to read.
Returns:
true on success, false on underflow.
function syn_cdr_read_double¶
Read 64-bit double (8-byte aligned).
Parameters:
rReader context.outOutput pointer.
Returns:
true on success, false on underflow.
function syn_cdr_read_float¶
Read 32-bit float (4-byte aligned).
Parameters:
rReader context.outOutput pointer.
Returns:
true on success, false on underflow.
function syn_cdr_read_i16¶
Read signed 16-bit integer (2-byte aligned).
Parameters:
rReader context.outOutput pointer.
Returns:
true on success, false on underflow.
function syn_cdr_read_i32¶
Read signed 32-bit integer (4-byte aligned).
Parameters:
rReader context.outOutput pointer.
Returns:
true on success, false on underflow.
function syn_cdr_read_i64¶
Read signed 64-bit integer (8-byte aligned).
Parameters:
rReader context.outOutput pointer.
Returns:
true on success, false on underflow.
function syn_cdr_read_i8¶
Read signed 8-bit integer.
Parameters:
rReader context.outOutput pointer.
Returns:
true on success, false on underflow.
function syn_cdr_read_string¶
Read null-terminated string with length prefix.
Parameters:
rReader context.out_bufOutput string buffer.max_lenCapacity of output string buffer.
Returns:
true on success, false on underflow/truncation.
function syn_cdr_read_u16¶
Read unsigned 16-bit integer (2-byte aligned).
Parameters:
rReader context.outOutput pointer.
Returns:
true on success, false on underflow.
function syn_cdr_read_u32¶
Read unsigned 32-bit integer (4-byte aligned).
Parameters:
rReader context.outOutput pointer.
Returns:
true on success, false on underflow.
function syn_cdr_read_u64¶
Read unsigned 64-bit integer (8-byte aligned).
Parameters:
rReader context.outOutput pointer.
Returns:
true on success, false on underflow.
function syn_cdr_read_u8¶
Read unsigned 8-bit integer.
Parameters:
rReader context.outOutput pointer.
Returns:
true on success, false on underflow.
function syn_cdr_reader_init¶
Initialize CDR reader.
Parameters:
rReader context.bufInput buffer.sizeBuffer size.
function syn_cdr_write_bool¶
Write boolean.
Parameters:
wWriter context.vValue.
Returns:
true on success, false on overflow.
function syn_cdr_write_bytes¶
Write raw byte buffer without alignment padding.
Parameters:
wWriter context.bytesData buffer.lenNumber of bytes.
Returns:
true on success, false on overflow.
function syn_cdr_write_double¶
Write 64-bit double (8-byte aligned).
Parameters:
wWriter context.vValue.
Returns:
true on success, false on overflow.
function syn_cdr_write_float¶
Write 32-bit float (4-byte aligned).
Parameters:
wWriter context.vValue.
Returns:
true on success, false on overflow.
function syn_cdr_write_i16¶
Write signed 16-bit integer (2-byte aligned).
Parameters:
wWriter context.vValue.
Returns:
true on success, false on overflow.
function syn_cdr_write_i32¶
Write signed 32-bit integer (4-byte aligned).
Parameters:
wWriter context.vValue.
Returns:
true on success, false on overflow.
function syn_cdr_write_i64¶
Write signed 64-bit integer (8-byte aligned).
Parameters:
wWriter context.vValue.
Returns:
true on success, false on overflow.
function syn_cdr_write_i8¶
Write signed 8-bit integer.
Parameters:
wWriter context.vValue.
Returns:
true on success, false on overflow.
function syn_cdr_write_string¶
Write null-terminated string with 32-bit length prefix and null terminator.
Parameters:
wWriter context.strString pointer.
Returns:
true on success, false on overflow.
function syn_cdr_write_u16¶
Write unsigned 16-bit integer (2-byte aligned).
Parameters:
wWriter context.vValue.
Returns:
true on success, false on overflow.
function syn_cdr_write_u32¶
Write unsigned 32-bit integer (4-byte aligned).
Parameters:
wWriter context.vValue.
Returns:
true on success, false on overflow.
function syn_cdr_write_u64¶
Write unsigned 64-bit integer (8-byte aligned).
Parameters:
wWriter context.vValue.
Returns:
true on success, false on overflow.
function syn_cdr_write_u8¶
Write unsigned 8-bit integer.
Parameters:
wWriter context.vValue.
Returns:
true on success, false on overflow.
function syn_cdr_writer_init¶
Initialize CDR writer.
Parameters:
wWriter context.bufTarget buffer.sizeBuffer size.
function syn_xrce_client_create_datareader¶
Create a DDS DataReader entity.
SYN_Status syn_xrce_client_create_datareader (
SYN_XRCE_Client * client,
uint16_t reader_id,
uint16_t subscriber_id,
uint16_t topic_id
)
Parameters:
clientClient instance.reader_idObject ID for the reader.subscriber_idParent subscriber ID.topic_idAssociated topic ID.
Returns:
SYN_OK on success.
function syn_xrce_client_create_datawriter¶
Create a DDS DataWriter entity.
SYN_Status syn_xrce_client_create_datawriter (
SYN_XRCE_Client * client,
uint16_t writer_id,
uint16_t publisher_id,
uint16_t topic_id
)
Parameters:
clientClient instance.writer_idObject ID for the writer.publisher_idParent publisher ID.topic_idAssociated topic ID.
Returns:
SYN_OK on success.
function syn_xrce_client_create_participant¶
Create a DDS DomainParticipant entity.
Parameters:
clientClient instance.participant_idObject ID for the participant.
Returns:
SYN_OK on success.
function syn_xrce_client_create_publisher¶
Create a DDS Publisher entity.
SYN_Status syn_xrce_client_create_publisher (
SYN_XRCE_Client * client,
uint16_t publisher_id,
uint16_t participant_id
)
Parameters:
clientClient instance.publisher_idObject ID for the publisher.participant_idParent participant ID.
Returns:
SYN_OK on success.
function syn_xrce_client_create_session¶
Connect and establish session with Micro-ROS Agent.
Parameters:
clientClient instance.
Returns:
SYN_OK on success, SYN_ERROR on transport failure.
function syn_xrce_client_create_subscriber¶
Create a DDS Subscriber entity.
SYN_Status syn_xrce_client_create_subscriber (
SYN_XRCE_Client * client,
uint16_t subscriber_id,
uint16_t participant_id
)
Parameters:
clientClient instance.subscriber_idObject ID for the subscriber.participant_idParent participant ID.
Returns:
SYN_OK on success.
function syn_xrce_client_create_topic¶
Create a DDS Topic entity.
SYN_Status syn_xrce_client_create_topic (
SYN_XRCE_Client * client,
uint16_t topic_id,
uint16_t participant_id,
const char * topic_name,
const char * type_name
)
Parameters:
clientClient instance.topic_idObject ID for the topic.participant_idParent participant ID.topic_nameROS 2 topic name (e.g. "sensors/imu").type_nameROS 2 type identifier (e.g. "sensor_msgs::msg::dds_::Imu_").
Returns:
SYN_OK on success.
function syn_xrce_client_init¶
Initialize Micro XRCE-DDS Client.
Parameters:
clientClient context to initialize.cfgConfiguration options and buffers.
Returns:
SYN_OK on success, SYN_INVALID_PARAM on invalid argument.
function syn_xrce_client_pt¶
Protothread continuation function for syn_sched .
Parameters:
ptProtothread continuation structure.taskTask handle containing SYN_XRCE_Client in user_data.
Returns:
SYN_PT_Status continuation status.
function syn_xrce_client_read_data¶
Request incoming topic samples from an active DataReader.
Parameters:
clientClient instance.reader_idDataReader entity ID.
Returns:
SYN_OK on success.
function syn_xrce_client_step¶
Advance the XRCE-DDS client state machine by one step / tick.
Parameters:
clientClient instance.now_msCurrent timestamp in milliseconds.
Returns:
SYN_OK on success.
function syn_xrce_client_write_data¶
Publish CDR serialized data payload to a DataWriter.
SYN_Status syn_xrce_client_write_data (
SYN_XRCE_Client * client,
uint16_t writer_id,
const uint8_t * data,
size_t len
)
Parameters:
clientClient instance.writer_idDataWriter entity ID.dataCDR payload buffer.lenPayload length.
Returns:
SYN_OK on success.
Macro Definition Documentation¶
define SYN_XRCE_CLIENT_KEY_DEFAULT¶
Default 32-bit client key
define SYN_XRCE_COOKIE¶
XRCE Header cookie
define SYN_XRCE_MAX_OBJECTS¶
Max simultaneously tracked entities
define SYN_XRCE_MAX_TOPIC_NAME¶
Maximum topic string length
define SYN_XRCE_MAX_TYPE_NAME¶
Maximum type string length
define SYN_XRCE_OBJKIND_DATAREADER¶
Object kind: DataReader
define SYN_XRCE_OBJKIND_DATAWRITER¶
Object kind: DataWriter
define SYN_XRCE_OBJKIND_PARTICIPANT¶
Object kind: DomainParticipant
define SYN_XRCE_OBJKIND_PUBLISHER¶
Object kind: Publisher
define SYN_XRCE_OBJKIND_SUBSCRIBER¶
Object kind: Subscriber
define SYN_XRCE_OBJKIND_TOPIC¶
Object kind: Topic
define SYN_XRCE_SESSION_ID_DEFAULT¶
Default client session ID
define SYN_XRCE_STATUS_ERR_ALREADY_EXISTS¶
Status Error: Already exists
define SYN_XRCE_STATUS_ERR_INCOMPATIBLE¶
Status Error: Incompatible
define SYN_XRCE_STATUS_ERR_INVALID_DATA¶
Status Error: Invalid data
define SYN_XRCE_STATUS_ERR_RESOURCES¶
Status Error: Out of resources
define SYN_XRCE_STATUS_ERR_UNKNOWN_REF¶
Status Error: Unknown reference
define SYN_XRCE_STATUS_OK¶
Status: OK
define SYN_XRCE_STATUS_OK_MATCHED¶
Status: OK and matched
define SYN_XRCE_STREAM_BEST_EFFORT¶
Best-effort stream ID
define SYN_XRCE_STREAM_RELIABLE¶
Reliable stream ID
define SYN_XRCE_SUBMSG_ACKNACK¶
Submessage: ACKNACK
define SYN_XRCE_SUBMSG_CREATE¶
Submessage: CREATE
define SYN_XRCE_SUBMSG_CREATE_CLIENT¶
Submessage: CREATE_CLIENT
define SYN_XRCE_SUBMSG_DATA¶
Submessage: DATA
define SYN_XRCE_SUBMSG_DELETE¶
Submessage: DELETE
define SYN_XRCE_SUBMSG_HEARTBEAT¶
Submessage: HEARTBEAT
define SYN_XRCE_SUBMSG_READ_DATA¶
Submessage: READ_DATA
define SYN_XRCE_SUBMSG_STATUS¶
Submessage: STATUS
define SYN_XRCE_SUBMSG_WRITE_DATA¶
Submessage: WRITE_DATA
The documentation for this class was generated from the following file src/syntropic/proto/syn_xrce_dds.h