nros C API
Lightweight ROS 2 client for embedded real-time systems
Loading...
Searching...
No Matches
service.h
Go to the documentation of this file.
1
20#ifndef NROS_SERVICE_H
21#define NROS_SERVICE_H
22
23/* Type and function definitions live in <nros/nros_generated.h>.
24 * This per-module header is kept as a thin shim so existing code that
25 * does `#include <nros/service.h>` continues to compile. */
26#include "nros/types.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/* ===================================================================
33 * DEPRECATED spellings — phase-379 W5 (2026-08-27)
34 *
35 * `send_reply` -> `send_response`. rcl, rclcpp and rclrs all say
36 * `send_response`; our C said BOTH, with `nros_service_send_response` sitting
37 * beside `nros_service_send_reply_raw`. The live spelling is
38 * `nros_service_send_response_raw()` — `_raw` because that is the family
39 * convention for the byte-buffer entry points (`nros_publish_raw`,
40 * `nros_client_send_request_raw`), not because a non-raw twin exists.
41 *
42 * Both old spellings survive here as `NROS_DEPRECATED_MSG` `static inline`
43 * forwarders, the shape the `nros_param_*` family established in
44 * `nros/parameter.h`: an inline definition in a header has no external
45 * linkage, so every translation unit may define it and none of them export
46 * it. That makes `nros_service_send_response_raw` the only exported symbol
47 * and these a SOURCE compatibility promise, not a binary one — an object file
48 * built against the pre-rename library must be recompiled.
49 *
50 * `nros_service_send_response()` is the odd one: it was never an alias, it
51 * was a permanent `NROS_RET_NOT_INIT` stub from before the polling API
52 * existed, so no caller can ever have had it succeed. Forwarding it is
53 * therefore strictly an improvement on what it did — and it keeps the
54 * un-suffixed name from reading like a second, working entry point.
55 *
56 * Define NROS_NO_DEPRECATED_SERVICE_ALIASES to compile without any of it —
57 * for a consumer whose build is `-Werror` and who wants the old names to be a
58 * hard error rather than a warning.
59 *
60 * These are scheduled for removal; migrate.
61 * =================================================================== */
62
63#ifndef NROS_NO_DEPRECATED_SERVICE_ALIASES
64
65NROS_DEPRECATED_MSG("nros_service_send_reply_raw() is deprecated; use "
66 "nros_service_send_response_raw()")
67static inline nros_ret_t nros_service_send_reply_raw(struct nros_service_t* service,
68 int64_t sequence_number, const uint8_t* data,
69 size_t len) {
71}
72
73/* phase-379 W6 decision 1 (2026-09-03): `try_recv` -> `take`. rcl
74 * (`rcl_take_request`), rclcpp (`Service::take_request`) and our own RMW
75 * vtable (`take_request`) all spell the non-blocking consuming receive that
76 * way; only the user-facing layer said `try_recv`. Same `static inline`
77 * shape, same source-not-binary promise -- see `nros/subscription.h`. */
78
79NROS_DEPRECATED_MSG("nros_service_try_recv_request_raw() is deprecated; use "
80 "nros_service_take_request_raw()")
81static inline int32_t nros_service_try_recv_request_raw(struct nros_service_t* service,
82 uint8_t* buf, size_t buf_len,
83 int64_t* sequence_number) {
85}
86
87NROS_DEPRECATED_MSG("nros_service_send_response() is deprecated; use "
88 "nros_service_send_response_raw()")
89static inline nros_ret_t nros_service_send_response(struct nros_service_t* service,
90 int64_t sequence_number,
91 const uint8_t* response_data,
92 size_t response_len) {
94}
95
96#endif /* NROS_NO_DEPRECATED_SERVICE_ALIASES */
97
98#ifdef __cplusplus
99}
100#endif
101
102#endif /* NROS_SERVICE_H */
int nros_ret_t
Definition nros_generated.h:849
nros_ret_t nros_service_send_response_raw(struct nros_service_t *service, int64_t sequence_number, const uint8_t *data, size_t len)
int32_t nros_service_take_request_raw(struct nros_service_t *service, uint8_t *buf, size_t buf_len, int64_t *sequence_number)
uint8_t * buf
Definition service.h:82
int64_t const uint8_t * data
Definition service.h:68
int64_t const uint8_t * response_data
Definition service.h:91
uint8_t size_t buf_len
Definition service.h:82
int64_t sequence_number
Definition service.h:68
int64_t const uint8_t size_t len
Definition service.h:69
int64_t const uint8_t size_t response_len
Definition service.h:92
Definition nros_generated.h:2132
Shared types and constants for the nros C API.
#define NROS_DEPRECATED_MSG(msg)
Definition visibility.h:58