|
oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
|
RAII wrapper around an oveRTOS byte-stream (ring-buffer) object. More...
#include <stream.hpp>
Public Member Functions | |
| Stream (size_t trigger) | |
| Constructs and initialises the stream with the given receive trigger. | |
| ~Stream () | |
| Destroys the stream, releasing the underlying kernel resource. | |
| Stream (const Stream &)=delete | |
| Stream & | operator= (const Stream &)=delete |
| Stream (Stream &&other) noexcept | |
| Move constructor — transfers ownership of the kernel handle. | |
| Stream & | operator= (Stream &&other) noexcept |
| Move-assignment operator — transfers ownership of the kernel handle. | |
| int | send (const void *data, size_t len, uint32_t timeout_ms, size_t *bytes_sent) |
| Sends bytes into the stream from task context. | |
| int | receive (void *buf, size_t len, uint32_t timeout_ms, size_t *bytes_received) |
| Receives bytes from the stream from task context. | |
| int | send_from_isr (const void *data, size_t len, size_t *bytes_sent) |
| Sends bytes into the stream from an ISR context (non-blocking). | |
| int | receive_from_isr (void *buf, size_t len, size_t *bytes_received) |
| Receives bytes from the stream from an ISR context (non-blocking). | |
| int | reset () |
| Resets the stream, discarding any buffered data. | |
| size_t | bytes_available () const |
| Returns the number of bytes currently available to read. | |
| bool | valid () const |
Returns true if the underlying kernel handle is non-null. | |
| ove_stream_t | handle () const |
| Returns the raw oveRTOS stream handle. | |
RAII wrapper around an oveRTOS byte-stream (ring-buffer) object.
A stream provides a producer/consumer byte buffer with configurable capacity and a watermark trigger level. Receivers block until at least trigger bytes are available; senders block if the buffer is full.
In zero-heap mode the buffer is stored inline in the wrapper.
| BufSize | Compile-time buffer capacity in bytes (must be > 0). |
|
inlineexplicit |
Constructs and initialises the stream with the given receive trigger.
Only participates in overload resolution when BufSize > 0.
| [in] | trigger | Minimum number of bytes that must be available before a blocked receiver is woken. |
Asserts at startup if initialisation fails.
|
inlinenoexcept |
Move constructor — transfers ownership of the kernel handle.
| other | The source; its handle is set to null after the move. |
|
inlinenoexcept |
Move-assignment operator — transfers ownership of the kernel handle.
| other | The source; its handle is set to null after the move. |
|
inline |
Sends bytes into the stream from task context.
| [in] | data | Pointer to the data to send. |
| [in] | len | Number of bytes to send. |
| [in] | timeout_ms | Maximum time to wait if the buffer is full. |
| [out] | bytes_sent | Receives the number of bytes actually written. |
OVE_OK on success, or a negative error code.
|
inline |
Receives bytes from the stream from task context.
| [out] | buf | Buffer to receive the data. |
| [in] | len | Maximum number of bytes to read. |
| [in] | timeout_ms | Maximum time to wait for data. |
| [out] | bytes_received | Receives the number of bytes actually read. |
OVE_OK on success, or a negative error code.
|
inline |
Sends bytes into the stream from an ISR context (non-blocking).
| [in] | data | Pointer to the data to send. |
| [in] | len | Number of bytes to send. |
| [out] | bytes_sent | Receives the number of bytes actually written. |
OVE_OK on success, or a negative error code if the buffer is full.
|
inline |
Receives bytes from the stream from an ISR context (non-blocking).
| [out] | buf | Buffer to receive the data. |
| [in] | len | Maximum number of bytes to read. |
| [out] | bytes_received | Receives the number of bytes actually read. |
OVE_OK on success, or a negative error code if insufficient data.
|
inline |
Resets the stream, discarding any buffered data.
OVE_OK on success, or a negative error code.
|
inline |
Returns the number of bytes currently available to read.
|
inline |
Returns true if the underlying kernel handle is non-null.
true when the stream was successfully initialised.
|
inline |
Returns the raw oveRTOS stream handle.
ove_stream_t handle.