nros C API
Lightweight ROS 2 client for embedded real-time systems
Loading...
Searching...
No Matches
subscription.h
Go to the documentation of this file.
1
16#ifndef NROS_SUBSCRIPTION_H
17#define NROS_SUBSCRIPTION_H
18
19/* Type and function definitions live in <nros/nros_generated.h>.
20 * This per-module header is kept as a thin shim so existing code that
21 * does `#include <nros/subscription.h>` continues to compile. */
22#include "nros/types.h"
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/* ===================================================================
29 * DEPRECATED spellings — phase-379 W6 decision 1 (2026-09-03)
30 *
31 * `try_recv` -> `take`. rcl (`rcl_take`), rclcpp
32 * (`Subscription::take`) and our OWN RMW vtable (`take`, `take_request`,
33 * `take_response`, `take_sequence`) all spell the non-blocking consuming
34 * receive that way; only the user-facing layer said `try_recv`, which is
35 * Rust-channel vocabulary that reads as a different contract to a ROS 2
36 * user. Both forms are non-blocking and both report emptiness without
37 * failing, so no platform constraint asked for the other word.
38 *
39 * `_raw` -> `_serialized` for the pre-CDR byte form, because that is
40 * ROS 2's word for it (`rcl_take_serialized_message`).
41 *
42 * The forwarders are `NROS_DEPRECATED_MSG` `static inline`, the shape the
43 * `nros_param_*` family established in `nros/parameter.h`: an inline
44 * definition in a header has no external linkage, so every translation
45 * unit may define it and none of them export it. The `take_*` name stays
46 * the ONLY exported symbol — this is a SOURCE compatibility promise, not
47 * a binary one, and an object file built against the pre-rename library
48 * must be recompiled.
49 *
50 * Define NROS_NO_DEPRECATED_SUBSCRIPTION_ALIASES to compile without any
51 * of it — for a consumer whose build is `-Werror` and who wants the old
52 * names to be a hard error rather than a warning.
53 *
54 * These are scheduled for removal; migrate.
55 * =================================================================== */
56
57#ifndef NROS_NO_DEPRECATED_SUBSCRIPTION_ALIASES
58
59NROS_DEPRECATED_MSG("nros_subscription_try_recv_raw() is deprecated; use "
60 "nros_subscription_take_serialized()")
61static inline int32_t nros_subscription_try_recv_raw(struct nros_subscription_t* subscription,
62 uint8_t* buf, size_t buf_len) {
63 return nros_subscription_take_serialized(subscription, buf, buf_len);
64}
65
66NROS_DEPRECATED_MSG("nros_subscription_try_recv_sequence() is deprecated; use "
67 "nros_subscription_take_sequence()")
68static inline int32_t nros_subscription_try_recv_sequence(struct nros_subscription_t* subscription,
69 uint8_t* buf, size_t per_msg_cap,
70 size_t max_msgs, size_t* out_lens) {
72}
73
74NROS_DEPRECATED_MSG("nros_subscription_try_recv_validated() is deprecated; use "
75 "nros_subscription_take_validated()")
76static inline int32_t
77nros_subscription_try_recv_validated(struct nros_subscription_t* subscription, uint8_t* buf,
80}
81
82#endif /* NROS_NO_DEPRECATED_SUBSCRIPTION_ALIASES */
83
84#ifdef __cplusplus
85}
86#endif
87
88#endif /* NROS_SUBSCRIPTION_H */
int32_t nros_subscription_take_sequence(struct nros_subscription_t *subscription, uint8_t *buf, size_t per_msg_cap, size_t max_msgs, size_t *out_lens)
int32_t nros_subscription_take_validated(struct nros_subscription_t *subscription, uint8_t *buf, size_t buf_len, struct nros_integrity_status_t *out_status)
int32_t nros_subscription_take_serialized(struct nros_subscription_t *subscription, uint8_t *buf, size_t buf_len)
Definition nros_generated.h:2606
Definition nros_generated.h:1751
uint8_t size_t per_msg_cap
Definition subscription.h:69
uint8_t size_t size_t max_msgs
Definition subscription.h:70
uint8_t size_t size_t size_t * out_lens
Definition subscription.h:70
uint8_t size_t struct nros_integrity_status_t * out_status
Definition subscription.h:78
uint8_t size_t buf_len
Definition subscription.h:62
uint8_t * buf
Definition subscription.h:62
Shared types and constants for the nros C API.
#define NROS_DEPRECATED_MSG(msg)
Definition visibility.h:58