|
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 () noexcept | |
| 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. | |
| void | send (const void *data, size_t len, size_t &bytes_sent) |
| Sends bytes into the stream, blocking indefinitely. | |
| bool | try_send (const void *data, size_t len, size_t &bytes_sent) |
| Non-blocking send. | |
| template<class Rep , class Period > | |
| Result< void > | try_send_for (const void *data, size_t len, const std::chrono::duration< Rep, Period > &rel, size_t &bytes_sent) noexcept |
| Bounded-wait send. | |
| template<class Clock , class Duration > | |
| Result< void > | try_send_until (const void *data, size_t len, const std::chrono::time_point< Clock, Duration > &deadline, size_t &bytes_sent) noexcept |
| Deadline-based send templated over the clock. | |
| void | receive (void *buf, size_t len, size_t &bytes_received) |
| Receives bytes from the stream, blocking indefinitely. | |
| bool | try_receive (void *buf, size_t len, size_t &bytes_received) |
| Non-blocking receive. | |
| template<class Rep , class Period > | |
| Result< void > | try_receive_for (void *buf, size_t len, const std::chrono::duration< Rep, Period > &rel, size_t &bytes_received) noexcept |
| Bounded-wait receive. | |
| template<class Clock , class Duration > | |
| Result< void > | try_receive_until (void *buf, size_t len, const std::chrono::time_point< Clock, Duration > &deadline, size_t &bytes_received) noexcept |
| Deadline-based receive templated over the clock. | |
| Result< void > | send_from_isr (const void *data, size_t len, size_t &bytes_sent) noexcept |
| Sends bytes into the stream from an ISR context (non-blocking). | |
| Result< void > | receive_from_isr (void *buf, size_t len, size_t &bytes_received) noexcept |
| Receives bytes from the stream from an ISR context (non-blocking). | |
| Result< void > | reset () noexcept |
| 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, blocking indefinitely.
Forever-wait form: failure means the handle is unusable. Aborts via OVE_STATIC_INIT_ASSERT (same pattern as Queue::send). Even on success, bytes_sent may be less than len if the substrate's internal buffer dictates a smaller commit — caller must inspect bytes_sent.
| [in] | data | Pointer to the data to send. |
| [in] | len | Number of bytes to send. |
| [out] | bytes_sent | Number of bytes actually written. |
|
inline |
Non-blocking send.
| [out] | bytes_sent | Number of bytes actually written (may be < len even on success). |
true if any bytes were written, false if the buffer was full.
|
inlinenoexcept |
Bounded-wait send.
| [in] | data | Pointer to the data to send. |
| [in] | len | Number of bytes to send. |
| [in] | rel | Relative timeout (any std::chrono::duration unit). |
| [out] | bytes_sent | Number of bytes actually written (the substrate may write a non-zero count even on a Timeout failure if some bytes committed before the deadline — always inspect this). |
Result<void> on success; unexpected Error::Timeout if the deadline elapsed; unexpected with another Error value on backend failure.
|
inlinenoexcept |
Deadline-based send templated over the clock.
Same clock-templating rationale as Mutex::try_lock_until.
|
inline |
Receives bytes from the stream, blocking indefinitely.
Forever-wait form: failure means the handle is unusable. Aborts via OVE_STATIC_INIT_ASSERT. Like send, bytes_received may be less than len on success — caller must inspect it.
| [out] | buf | Buffer to receive the data. |
| [in] | len | Maximum number of bytes to read. |
| [out] | bytes_received | Number of bytes actually read. |
|
inline |
Non-blocking receive.
true if any bytes were read, false if the buffer was empty.
|
inlinenoexcept |
Bounded-wait receive.
| [out] | buf | Destination buffer. |
| [in] | len | Maximum bytes to read. |
| [in] | rel | Relative timeout. |
| [out] | bytes_received | Number of bytes actually read (may be non-zero even on a Timeout failure if some bytes arrived before the deadline). |
Result<void> on success; unexpected Error::Timeout / Error::Eof / backend-specific Error otherwise.
|
inlinenoexcept |
Deadline-based receive templated over the clock.
|
inlinenoexcept |
Sends bytes into the stream from an ISR context (non-blocking).
| [out] | bytes_sent | Number of bytes actually written (may be non-zero even on Error::QueueFull when a partial commit succeeded before the buffer filled). |
Result<void> on full success; unexpected with the appropriate Error variant otherwise.
|
inlinenoexcept |
Receives bytes from the stream from an ISR context (non-blocking).
| [out] | bytes_received | Number of bytes actually read (may be non-zero even on a failure if partial data was available). |
Result<void> on full success; unexpected with the appropriate Error variant otherwise.
|
inlinenoexcept |
Resets the stream, discarding any buffered data.
Result<void> on success; unexpected Error on failure.
|
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.