#include <uart_non_blocking.h>
Represents an abstract UART interface.
The UartNonBlocking
interface provides a basic set of methods for performing Non-Blocking UART communication.
◆ CancelFlushOutput()
bool pw::uart::UartNonBlocking::CancelFlushOutput |
( |
| ) |
|
|
inline |
Cancels a pending FlushOutput() operation.
This function will cancel an output flush in progress. The FlushOutput callback will be called with status=CANCELLED.
- Returns
embed:rst:leading-asterisk
*
* true: The operation was successfully canceled a transaction in progress
* and the callback will be invoked with status=CANCELLED.
* false: There were no transactions in progress and nothing was
* cancelled. No callback will be invoked.
*
*
◆ CancelRead()
bool pw::uart::UartNonBlocking::CancelRead |
( |
| ) |
|
|
inline |
Cancel a current read in progress.
This function will cancel a read in progress. The read's callback will be invoked with status=CANCELLED.
- Returns
embed:rst:leading-asterisk
*
* true: The operation was successfully canceled a transaction in progress
* and the callback will be invoked with status=CANCELLED.
* false: There were no transactions in progress and nothing was
* cancelled. No callback will be invoked.
*
*
◆ CancelWrite()
bool pw::uart::UartNonBlocking::CancelWrite |
( |
| ) |
|
|
inline |
Cancel a current write in progress.
This function will cancel a write in progress. The write's callback will be called with status=CANCELLED.
- Returns
embed:rst:leading-asterisk
*
* true: The operation was successfully canceled a transaction in progress
* and the callback will be invoked with status=CANCELLED.
* false: There were no transactions in progress and nothing was
* cancelled. No callback will be invoked.
*
*
◆ DoCancelFlushOutput()
virtual bool pw::uart::UartNonBlocking::DoCancelFlushOutput |
( |
| ) |
|
|
inlineprivatevirtual |
Cancels a pending FlushOutput() operation.
This function will cancel an output flush in progress. The DoFlushOutput callback will be called with status=CANCELLED.
- Returns
embed:rst:leading-asterisk
*
* true: The operation was successfully canceled a transaction in progress
* and the callback will be invoked with status=CANCELLED.
* false: There were no transactions in progress and nothing was
* cancelled. No callback will be invoked.
*
*
◆ DoCancelRead()
virtual bool pw::uart::UartNonBlocking::DoCancelRead |
( |
| ) |
|
|
privatepure virtual |
Cancels a current read in progress.
This virtual function will cancel a read in progress. The read's callback will be called with status=CANCELLED.
- Returns
embed:rst:leading-asterisk
*
* true: The operation was successfully canceled a transaction in progress
* and the callback will be invoked with status=CANCELLED.
* false: There were no transactions in progress and nothing was
* cancelled. No callback will be invoked.
*
* May return other implementation-specific status codes.
*
*
◆ DoCancelWrite()
virtual bool pw::uart::UartNonBlocking::DoCancelWrite |
( |
| ) |
|
|
privatepure virtual |
Cancel a current write in progress.
This virtual function will cancel a write in progress. The write's callback will be invoked with status=CANCELLED.
- Returns
embed:rst:leading-asterisk
*
* true: The operation was successfully canceled a transaction in progress
* and the callback will be invoked with status=CANCELLED.
* false: There were no transactions in progress and nothing was
* cancelled. No callback will be invoked.
*
* May return other implementation-specific status codes.
*
*
◆ DoFlushOutput()
Ensures all queued data in the UART has been transmitted and the hardware FIFO is empty.
This function ensures that all data enqueued before calling this function has been transmitted. Any data enqueued after this function completes will be transmitted immediately.
- Parameters
-
callback | A callback to invoke when the flush is completed. |
status | OK: The operation was successful and the transmit FIFO is empty. CANCELLED: The operation was cancelled via CancelFlushOutput(). May return other implementation-specific status codes. |
- Returns
embed:rst:leading-asterisk
*
* .. pw-status-codes::
*
* OK: The operation was successfully started.
* UNAVAILABLE: Another Write() or FlushOutput() operation is currently
* in progress.
*
* May return other implementation-specific status codes.
*
*
◆ DoRead()
virtual Status pw::uart::UartNonBlocking::DoRead |
( |
ByteSpan |
rx_buffer, |
|
|
size_t |
min_bytes, |
|
|
Function< void(Status status, ConstByteSpan buffer)> && |
callback |
|
) |
| |
|
privatepure virtual |
Reads at least min_bytes
and at most rx_buffer.size()
bytes from the UART into the provided buffer.
This virtual function attempts to read data into the provided byte buffer (rx_buffer
). This virtual function will return immediately. callback
will be invoked when the buffer has been filled with at least min_bytes
, or an error occurs. Implementation Notes:
- The callback may be called in ISR context.
- The callback must be moved and stored prior to its invocation.
- Do not hold a lock when invoking the callback.
- Parameters
-
rx_buffer | The buffer to read data into. |
min_bytes | Minimum bytes to read. |
callback | A callback to invoke when the transaction is completed. |
status | OK: The operation was successful and the buffer has been filled with at least min_bytes with data. CANCELLED: The operation was cancelled via CancelRead(). May return other implementation-specific status codes. |
buffer | buffer.size() returns the number of bytes successfully read into the buffer. |
- Returns
embed:rst:leading-asterisk
*
* .. pw-status-codes::
*
* OK: The operation was successful started.
* UNAVAILABLE: Another Read() transaction is currently in progress.
*
* May return other implementation-specific status codes.
*
*
◆ DoWrite()
Writes data from a provided buffer to the UART.
This virtual function attempts to write data from the provided byte buffer (tx_buffer
). This virtual function will return immediately. callback
will be invoked when either the buffer fully written, or an error occurs. Implementation Notes:
- The callback may be called in ISR context.
- The callback must be moved and stored prior to its invocation.
- Do not hold a lock when invoking the callback.
- Parameters
-
tx_buffer | The buffer to write to the UART. |
callback | A callback to invoke when the transaction is completed. |
status | status.size() returns the number of bytes successfully written from tx_buffer . |
status | OK: The operation was successful and the entire buffer has been written. CANCELLED: The operation was cancelled via CancelWrite(). May return other implementation-specific status codes. |
- Returns
embed:rst:leading-asterisk
*
* .. pw-status-codes::
*
* OK: The operation was successful started.
* UNAVAILABLE: Another Write() transaction is currently in progress.
*
* May return other implementation-specific status codes.
*
*
◆ FlushOutput()
Ensures all queued data in the UART has been transmitted and the hardware FIFO is empty.
This function ensures that all data enqueued before calling this function has been transmitted. Any data enqueued after this function completes will be transmitted immediately.
- Parameters
-
callback | A callback to invoke when the flush is completed. |
status | OK: The operation was successful and the transmit FIFO is empty. CANCELLED: The operation was cancelled via CancelFlushOutput(). May return other implementation-specific status codes. |
- Returns
embed:rst:leading-asterisk
*
* .. pw-status-codes::
*
* OK: The operation was successfully started.
* UNAVAILABLE: Another Write() or FlushOutput() operation is currently
* in progress.
*
* May return other implementation-specific status codes.
*
*
◆ ReadAtLeast()
Status pw::uart::UartNonBlocking::ReadAtLeast |
( |
ByteSpan |
rx_buffer, |
|
|
size_t |
min_bytes, |
|
|
Function< void(Status status, ConstByteSpan buffer)> && |
callback |
|
) |
| |
|
inline |
Reads at least min_bytes
and at most rx_buffer.size()
bytes from the UART into the provided buffer.
This function calls callback
after rx_buffer
is filled with at least min_bytes
of data. This may be called from interrupt context. The callback may be called in ISR context. It is not safe to call any Uart methods from the callback context.
- Parameters
-
rx_buffer | The buffer to read data into. |
min_bytes | Minimum bytes to read. |
callback | A callback to invoke when the transaction is completed. |
status | OK: The operation was successful and the buffer has been filled with at least min_bytes with data. CANCELLED: The operation was cancelled via CancelRead(). May return other implementation-specific status codes. |
buffer | buffer.size() returns the number of bytes successfully read into the buffer. |
- Returns
embed:rst:leading-asterisk
*
* .. pw-status-codes::
*
* OK: The operation was successfully started.
* UNAVAILABLE: Another Read() transaction is currently in progress.
*
* May return other implementation-specific status codes.
*
*
◆ ReadExactly()
Status pw::uart::UartNonBlocking::ReadExactly |
( |
ByteSpan |
rx_buffer, |
|
|
Function< void(Status status, ConstByteSpan buffer)> && |
callback |
|
) |
| |
|
inline |
Reads exactly rx_buffer.size()
bytes from the UART into the provided buffer.
This function calls callback
after the entirety of rx_buffer
is filled with data. This may be called from interrupt context. The callback may be called in ISR context. It is not safe to call any Uart methods from the callback context.
- Parameters
-
rx_buffer | The buffer to read data into. |
callback | A callback to invoke when the transaction is completed. |
status | OK: The operation was successful and the entire buffer has been filled with data. CANCELLED: The operation was cancelled via CancelRead(). May return other implementation-specific status codes. |
buffer | buffer.size() returns the number of bytes successfully read into the buffer. If status =OK, the buffer is identical to rx_buffer |
- Returns
embed:rst:leading-asterisk
*
* .. pw-status-codes::
*
* OK: The operation was successfully started.
* UNAVAILABLE: Another Read() transaction is currently in progress.
*
* May return other implementation-specific status codes.
*
*
◆ Write()
Writes data from a provided buffer to the UART.
This function calls callback
after the entirety of tx_buffer
is written to the UART. This may be called from interrupt context. The callback may be called in ISR context. It is not safe to call any Uart methods from the callback context.
- Parameters
-
tx_buffer | The buffer to write to the UART. |
callback | A callback to invoke when the transaction is completed. |
status | status.size() returns the number of bytes successfully written from tx_buffer . OK: The operation was successful and the entire buffer has been written. CANCELLED: The operation was cancelled via CancelWrite(). May return other implementation-specific status codes. |
- Returns
embed:rst:leading-asterisk
*
* .. pw-status-codes::
*
* OK: The operation was successfully started.
* UNAVAILABLE: Another Write() transaction is currently in progress.
*
* May return other implementation-specific status codes.
*
*
The documentation for this class was generated from the following file: