oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ove::Uart< RxBufSize > Class Template Reference

RAII wrapper around an oveRTOS UART peripheral. More...

#include <uart.hpp>

Public Member Functions

 Uart (const struct ove_uart_cfg &cfg)
 Construct and initialise a UART port from cfg.
 
 Uart (const Uart &)=delete
 
Uartoperator= (const Uart &)=delete
 
 Uart (Uart &&o) noexcept
 Move constructor — transfers handle; source becomes empty.
 
Uartoperator= (Uart &&o) noexcept
 Move-assignment — destroys current port, then takes o's handle.
 
Result< size_t > write (const void *data, size_t len, std::chrono::nanoseconds timeout=wait_forever) noexcept
 Write bytes to the port.
 
Result< size_t > read (void *buf, size_t len, std::chrono::nanoseconds timeout=wait_forever) noexcept
 Read bytes from the RX buffer.
 
size_t bytes_available () const
 Bytes currently available in the RX buffer.
 
Result< void > flush () noexcept
 Block until all pending TX bytes have been drained.
 
ove_uart_t handle () const
 Returns the underlying C handle.
 

Detailed Description

template<size_t RxBufSize = 0>
class ove::Uart< RxBufSize >

RAII wrapper around an oveRTOS UART peripheral.

In zero-heap mode the RX buffer is stored inline.

Template Parameters
RxBufSizeCompile-time RX buffer capacity in bytes.

Not copyable. Move-only when heap allocation is enabled.

Constructor & Destructor Documentation

◆ Uart()

template<size_t RxBufSize = 0>
ove::Uart< RxBufSize >::Uart ( const struct ove_uart_cfg &  cfg)
inlineexplicit

Construct and initialise a UART port from cfg.

Parameters
[in]cfgPort configuration (baud, parity, stop bits, flow control).

Member Function Documentation

◆ write()

template<size_t RxBufSize = 0>
Result< size_t > ove::Uart< RxBufSize >::write ( const void *  data,
size_t  len,
std::chrono::nanoseconds  timeout = wait_forever 
)
inlinenoexcept

Write bytes to the port.

Returns
On success, number of bytes actually written. On failure, an unexpected Error.

◆ read()

template<size_t RxBufSize = 0>
Result< size_t > ove::Uart< RxBufSize >::read ( void *  buf,
size_t  len,
std::chrono::nanoseconds  timeout = wait_forever 
)
inlinenoexcept

Read bytes from the RX buffer.

Returns
On success, number of bytes actually read. On failure, an unexpected Error.

The documentation for this class was generated from the following file: