nros rmw-cffi
C vtable for plugging a third-party RMW backend into nros
Loading...
Searching...
No Matches
Data Fields
nros_transport_ops_t Struct Reference

#include <rmw_transport.h>

Data Fields

uint32_t _reserved
 
uint32_t abi_version
 
void(* close )(void *user_data)
 
int32_t(* open )(void *user_data, const void *params)
 
int32_t(* read )(void *user_data, uint8_t *buf, size_t len, uint32_t timeout_ms)
 
void * user_data
 
int32_t(* write )(void *user_data, const uint8_t *buf, size_t len)
 

Detailed Description

Runtime-pluggable custom transport. The runtime never dereferences user_data; it's the caller's per-transport context, threaded back into every callback's first argument.

THIS declaration is the ABI single source of truth (RFC-0054): Rust consumes the committed bindgen output of this header, and nros_rmw::NrosTransportOps is the hand-written Rust-side view kept in lockstep with it — not the other way round. The previous wording had that backwards (issue 0331). Layout equivalence is asserted on both sides: see nros_transport_ops_t in nros-rmw-cffi/tests/c_stubs/abi_layout_check.c and the const _ size/align block beside nros_rmw_cffi_set_custom_transport in nros-rmw-cffi/src/lib.rs. Same layout, same threading contract, same return codes.

Field Documentation

◆ _reserved

uint32_t nros_transport_ops_t::_reserved

Reserved padding for alignment stability across appends. Set to zero.

◆ abi_version

uint32_t nros_transport_ops_t::abi_version

ABI version. MUST equal NROS_TRANSPORT_OPS_ABI_VERSION_V1. Any other value is rejected at registration time with NROS_RMW_RET_INCOMPATIBLE_ABI.

◆ close

void(* nros_transport_ops_t::close) (void *user_data)

Tear the transport down. After close returns, the runtime will not invoke read or write on this transport unless nros_set_custom_transport is called again.

◆ open

int32_t(* nros_transport_ops_t::open) (void *user_data, const void *params)

Open the underlying medium.

Parameters
user_dataCaller-supplied context.
paramsOpaque per-transport metadata (e.g. UART baud rate, USB-CDC endpoint id). May be NULL.
Return values
NROS_RMW_RET_OKon success.
<0on failure (any rmw_ret_t error code).

◆ read

int32_t(* nros_transport_ops_t::read) (void *user_data, uint8_t *buf, size_t len, uint32_t timeout_ms)

Receive up to len bytes into buf within timeout_ms.

Return values
>=0number of bytes read (may be less than len).
<0on error / timeout (any rmw_ret_t error code).

◆ user_data

void* nros_transport_ops_t::user_data

Opaque caller context, threaded back into every callback. Lifetime: must outlive the transport's active period (i.e. until close returns).

◆ write

int32_t(* nros_transport_ops_t::write) (void *user_data, const uint8_t *buf, size_t len)

Send len bytes from buf. Must NOT block beyond a brief hardware retry; long blocking should surface as NROS_RMW_RET_TIMEOUT.

Return values
NROS_RMW_RET_OKon success.
<0on failure (any rmw_ret_t error code).

The documentation for this struct was generated from the following file: