Skip to content

Commit 712cf77

Browse files
committed
doc: kernel c wrapper
1 parent 0372e8a commit 712cf77

1 file changed

Lines changed: 118 additions & 28 deletions

File tree

include/robotkernel/kernel_c_wrapper.h

Lines changed: 118 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,61 +24,151 @@
2424
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2525
*/
2626

27-
#ifndef PD_SFUN_HELPER_H
28-
#define PD_SFUN_HELPER_H
27+
/**
28+
* @file kernel_c_wrapper.h
29+
* @brief C interface for accessing robotkernel process data.
30+
*
31+
* This header exposes a minimal C API for retrieving and
32+
* managing process data handles, buffers, and synchronization.
33+
* It is intended for use when linking against robotkernel
34+
* from plain C code or foreign language bindings.
35+
*
36+
* @note
37+
* All functions are extern "C" to ensure stable symbols.
38+
* The API works with opaque pdhandle pointers.
39+
*/
40+
41+
#ifndef ROBOTKERNEL__KERNEL_C_WRAPPER__H
42+
#define ROBOTKERNEL__KERNEL_C_WRAPPER__H
2943

3044
#include <stdint.h>
3145

46+
#ifdef __cplusplus
3247
extern "C" {
48+
#endif
3349

50+
/**
51+
* @typedef pdhandle
52+
* @brief Opaque handle to a robotkernel process data instance.
53+
*
54+
* This handle represents either a *consumer* or *provider*
55+
* registration for robotkernel process data.
56+
* It must be released with kernel_c_release_pd_handle().
57+
*/
3458
typedef void * pdhandle; //!< handle to robotkernel-5 process data
3559

36-
//! Retreave a handle to a robotkernel-5 process data (registers as consumer or provider)
37-
/*!
38-
* \param[in] pd_name Name of robotkernel-5 process data.
39-
* \param[in] consumer If 1 register as consumer, otherwise as provider.
40-
* \returns handle to process data device
60+
/**
61+
* @brief Retrieve a handle to robotkernel process data.
62+
*
63+
* This call registers the caller as either a *consumer* or
64+
* *provider* for the named process data.
65+
*
66+
* Once acquired:
67+
* - Consumers can read inputs and negotiate buffers.
68+
* - Providers can write outputs and commit them.
69+
*
70+
* @param[in] pd_name
71+
* Null-terminated name of the process data entity
72+
* (typically defined in the robotkernel configuration).
73+
*
74+
* @param[in] consumer
75+
* If non-zero, register as a *consumer*.
76+
* Otherwise, register as a *provider*.
77+
*
78+
* @return
79+
* A handle usable for subsequent API calls,
80+
* or `nullptr` on failure.
4181
*/
4282
pdhandle kernel_c_get_pd_handle(const char *pd_name, int consumer);
4383

44-
//! Checks if process data description does match .
45-
/*!
46-
* \param[in] hdl Handle of robotkernel-5 process data retreaved from <get_pd_handle>.
47-
* \param[in] desc Description to check against.
48-
* \return 0 on match, -1 otherwise.
84+
/**
85+
* @brief Check if a process data description matches an expected string.
86+
*
87+
* This function compares the internal process data description
88+
* with a provided textual description.
89+
*
90+
* @param[in] hdl
91+
* Previously acquired handle (from kernel_c_get_pd_handle()).
92+
*
93+
* @param[in] desc
94+
* Null-terminated description to check against.
95+
*
96+
* @return
97+
* `0` if the description matches,
98+
* `-1` otherwise.
4999
*/
50100
int kernel_c_check_pd_desc(pdhandle hdl, const char *desc);
51101

52-
//! Get next buffer to write (outputs data buffer)
53-
/*!
54-
* \param[in] hdl Handle of robotkernel-5 process data retreaved from <get_pd_handle>.
55-
* \return buffer for next outputs.
102+
/**
103+
* @brief Get pointer to the next write buffer.
104+
*
105+
* When acting as a provider, this returns a pointer to the
106+
* next output buffer that can be written to.
107+
*
108+
* After filling this buffer, the caller must commit it
109+
* with kernel_c_push_write_buffer().
110+
*
111+
* @param[in] hdl
112+
* A valid process data handle.
113+
*
114+
* @return
115+
* Pointer to a buffer of type `uint8_t*`
116+
* containing writable output data.
56117
*/
57118
uint8_t *kernel_c_next_write_buffer(pdhandle hdl);
58119

59-
//! Push next write buffer to be set as outputs.
60-
/*!
61-
* \param[in] hdl Handle of robotkernel-5 process data retreaved from <get_pd_handle>.
120+
/**
121+
* @brief Push the previously acquired write buffer.
122+
*
123+
* After writing to the buffer returned by
124+
* kernel_c_next_write_buffer(), this call commits
125+
* it as the current output image for the provider.
126+
*
127+
* @param[in] hdl
128+
* A valid process data handle.
62129
*/
63130
void kernel_c_push_write_buffer(pdhandle hdl);
64131

65-
/*! Get actual read buffer with valid inputs.
66-
* \param[in] hdl Handle of robotkernel-5 process data retreaved from <get_pd_handle>.
67-
* \return buffer to be read with valid inputs.
132+
/**
133+
* @brief Retrieve pointer to the current read buffer.
134+
*
135+
* For a consumer, this returns a pointer to the
136+
* latest buffer containing valid input data.
137+
*
138+
* @param[in] hdl
139+
* A valid process data handle.
140+
*
141+
* @return
142+
* Pointer to the current input buffer.
68143
*/
69144
uint8_t *kernel_c_act_read_buffer(pdhandle hdl);
70145

71-
/*! Set actual read buffer as read by application.
72-
* \param[in] hdl Handle of robotkernel-5 process data retreaved from <get_pd_handle>.
146+
/**
147+
* @brief Mark the current read buffer as read.
148+
*
149+
* After inspecting the buffer returned by
150+
* kernel_c_act_read_buffer(), the caller should
151+
* inform the system that the buffer was consumed.
152+
*
153+
* @param[in] hdl
154+
* A valid process data handle.
73155
*/
74156
void kernel_c_pop_read_buffer(pdhandle hdl);
75157

76-
/*! Release process data handle (Deregisters as consumer or provider)
77-
* \param[in] hdl Handle of robotkernel-5 process data retreaved from <get_pd_handle>.
158+
/**
159+
* @brief Release a previously acquired process data handle.
160+
*
161+
* Deregisters the consumer/provider and frees any
162+
* internal resources associated with the handle.
163+
*
164+
* @param[in] hdl
165+
* Handle obtained via kernel_c_get_pd_handle().
78166
*/
79167
void kernel_c_release_pd_handle(pdhandle hdl);
80168

81-
};
169+
#ifdef __cplusplus
170+
} // extern "C"
171+
#endif
82172

83-
#endif // PD_SFUN_HELPER_H
173+
#endif // ROBOTKERNEL__KERNEL_C_WRAPPER__H
84174

0 commit comments

Comments
 (0)