|
nros rmw-cffi
C vtable for plugging a third-party RMW backend into nros
|
#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) |
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.
| uint32_t nros_transport_ops_t::_reserved |
Reserved padding for alignment stability across appends. Set to zero.
| 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.
| 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.
| int32_t(* nros_transport_ops_t::open) (void *user_data, const void *params) |
Open the underlying medium.
| user_data | Caller-supplied context. |
| params | Opaque per-transport metadata (e.g. UART baud rate, USB-CDC endpoint id). May be NULL. |
| NROS_RMW_RET_OK | on success. |
| <0 | on failure (any rmw_ret_t error code). |
| 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.
| >=0 | number of bytes read (may be less than len). |
| <0 | on error / timeout (any rmw_ret_t error code). |
| 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).
| 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.
| NROS_RMW_RET_OK | on success. |
| <0 | on failure (any rmw_ret_t error code). |