Pigweed
 
Loading...
Searching...
No Matches
pw::uart::UartBlockingAdapter Class Referencefinal

#include <blocking_adapter.h>

Inheritance diagram for pw::uart::UartBlockingAdapter:
pw::uart::Uart pw::uart::UartBase

Public Member Functions

 UartBlockingAdapter (UartNonBlocking &uart)
 Constructs a UartBlockingAdapter for a UartNonBlocking device.
 
- Public Member Functions inherited from pw::uart::Uart
StatusWithSize ReadAtLeast (ByteSpan rx_buffer, size_t min_bytes)
 
StatusWithSize ReadExactly (ByteSpan rx_buffer)
 
Status Read (ByteSpan rx_buffer)
 
StatusWithSize TryReadAtLeastFor (ByteSpan rx_buffer, size_t min_bytes, chrono::SystemClock::duration timeout)
 
StatusWithSize TryReadExactlyFor (ByteSpan rx_buffer, chrono::SystemClock::duration timeout)
 
StatusWithSize TryReadFor (ByteSpan rx_buffer, chrono::SystemClock::duration timeout)
 
Status Write (ConstByteSpan tx_buffer)
 
StatusWithSize TryWriteFor (ConstByteSpan tx_buffer, chrono::SystemClock::duration timeout)
 
Status FlushOutput ()
 
- Public Member Functions inherited from pw::uart::UartBase
Status Enable ()
 
Status Disable ()
 
Status SetBaudRate (uint32_t baud_rate)
 
Status SetFlowControl (bool enable)
 
size_t ConservativeReadAvailable ()
 
Status ClearPendingReceiveBytes ()
 

Private Member Functions

StatusWithSize DoTryReadFor (ByteSpan rx_buffer, size_t min_bytes, std::optional< chrono::SystemClock::duration > timeout) override
 
StatusWithSize DoTryWriteFor (ConstByteSpan tx_buffer, std::optional< chrono::SystemClock::duration > timeout) override
 Writes data from a provided buffer to the UART with an optional timeout.
 

Detailed Description

UartBlockingAdapter provides the blocking Uart interface on top of a UartNonBlocking device.

Member Function Documentation

◆ DoClearPendingReceiveBytes()

Status pw::uart::UartBlockingAdapter::DoClearPendingReceiveBytes ( )
inlineoverrideprivatevirtual

Implements pw::uart::UartBase.

◆ DoConservativeReadAvailable()

size_t pw::uart::UartBlockingAdapter::DoConservativeReadAvailable ( )
inlineoverrideprivatevirtual

Implements pw::uart::UartBase.

◆ DoEnable()

Status pw::uart::UartBlockingAdapter::DoEnable ( bool  enable)
inlineoverrideprivatevirtual

Implements pw::uart::UartBase.

◆ DoFlushOutput()

Status pw::uart::UartBlockingAdapter::DoFlushOutput ( )
overrideprivatevirtual

Implements pw::uart::Uart.

◆ DoSetBaudRate()

Status pw::uart::UartBlockingAdapter::DoSetBaudRate ( uint32_t  baud_rate)
inlineoverrideprivatevirtual

Implements pw::uart::UartBase.

◆ DoSetFlowControl()

Status pw::uart::UartBlockingAdapter::DoSetFlowControl ( bool  enabled)
inlineoverrideprivatevirtual

Reimplemented from pw::uart::UartBase.

◆ DoTryReadFor()

StatusWithSize pw::uart::UartBlockingAdapter::DoTryReadFor ( ByteSpan  ,
size_t  ,
std::optional< chrono::SystemClock::duration  
)
overrideprivatevirtual

Reads data from the UART into a provided buffer with an optional timeout provided.

This virtual function attempts to read data into the provided byte buffer (rx_buffer). The operation will continue until either min_bytes have been read into the buffer, an error occurs, or the optional timeout duration expires.

Parameters
rx_bufferThe buffer to read data into.
min_bytesThe minimum number of bytes to read before returning.
timeoutAn optional timeout duration. If specified, the function will block for no longer than this duration. If zero, the function will immediately return with at least one hardware read operation attempt. If not specified, the function blocks until the buffer is full.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The operation was successful and the entire buffer has been
*     filled with data.
* 
*     DEADLINE_EXCEEDED: The operation timed out before the entire buffer
*     could be filled.
* 
*  May return other implementation-specific status codes.
* 
*  

Reimplemented from pw::uart::Uart.

◆ DoTryWriteFor()

StatusWithSize pw::uart::UartBlockingAdapter::DoTryWriteFor ( ConstByteSpan  tx_buffer,
std::optional< chrono::SystemClock::duration timeout 
)
overrideprivatevirtual

Writes data from a provided buffer to the UART with an optional timeout.

This virtual function attempts to write data from the provided byte buffer (tx_buffer) to the UART. The operation will continue until either the buffer is empty, an error occurs, or the optional timeout duration expires.

Parameters
tx_bufferThe buffer containing data to be written.
timeoutAn optional timeout duration. If specified, the function will block for no longer than this duration. If zero, the function will immediately return after at least one hardware write operation attempt. If not specified, the function blocks until the buffer is empty.
Returns
embed:rst:leading-asterisk
 
* 
*  .. pw-status-codes::
* 
*     OK: The operation was successful and the entire buffer has been
*     written.
* 
*     DEADLINE_EXCEEDED: The operation timed out before the entire buffer
*     could be written.
* 
*  May return other implementation-specific status codes.
* 
*  

Implements pw::uart::Uart.


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