HardFOC Core
API reference
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
hf::host::MockUart Class Reference

#include <MockUart.h>

Inheritance diagram for hf::host::MockUart:

Public Types

using OnWrite = std::function< void(MockUart &uart, const std::vector< uint8_t > &written)>
 

Public Member Functions

 MockUart (hf_port_num_t port=0) noexcept
 
 ~MockUart () noexcept override=default
 
bool Initialize () noexcept override
 
bool Deinitialize () noexcept override
 
hf_uart_err_t Write (const hf_u8_t *data, hf_u16_t length, hf_u32_t timeout_ms=0) noexcept override
 
hf_uart_err_t Read (hf_u8_t *data, hf_u16_t length, hf_u32_t timeout_ms=0) noexcept override
 
hf_u16_t BytesAvailable () noexcept override
 
hf_uart_err_t FlushTx () noexcept override
 
hf_uart_err_t FlushRx () noexcept override
 
int Printf (const char *format,...) noexcept override
 
void SetInitializeResult (bool ok) noexcept
 
void InjectRx (const std::vector< uint8_t > &bytes)
 
void InjectRx (const char *text)
 
void SetOnWrite (OnWrite on_write)
 
void FailNextWrite (hf_uart_err_t error, size_t count=1) noexcept
 
const std::vector< uint8_t > & TxBytes () const noexcept
 
const std::vector< std::vector< uint8_t > > & TxWrites () const noexcept
 
void ClearTx () noexcept
 
int FlushRxCalls () const noexcept
 

Private Attributes

bool init_result_ {true}
 
std::vector< uint8_t > tx_
 
std::vector< std::vector< uint8_t > > writes_
 
std::deque< uint8_t > rx_
 
OnWrite on_write_
 
hf_uart_err_t fail_error_ {hf_uart_err_t::UART_ERR_TRANSMISSION_FAILED}
 
size_t fail_count_ {0}
 
int flush_rx_calls_ {0}
 

Member Typedef Documentation

◆ OnWrite

using hf::host::MockUart::OnWrite = std::function<void(MockUart& uart, const std::vector<uint8_t>& written)>

Constructor & Destructor Documentation

◆ MockUart()

hf::host::MockUart::MockUart ( hf_port_num_t  port = 0)
explicitnoexcept

◆ ~MockUart()

hf::host::MockUart::~MockUart ( )
overridedefaultnoexcept

Member Function Documentation

◆ BytesAvailable()

hf_u16_t hf::host::MockUart::BytesAvailable ( )
overridenoexcept

◆ ClearTx()

void hf::host::MockUart::ClearTx ( )
noexcept

◆ Deinitialize()

bool hf::host::MockUart::Deinitialize ( )
inlineoverridenoexcept

◆ FailNextWrite()

void hf::host::MockUart::FailNextWrite ( hf_uart_err_t  error,
size_t  count = 1 
)
noexcept

◆ FlushRx()

hf_uart_err_t hf::host::MockUart::FlushRx ( )
overridenoexcept

◆ FlushRxCalls()

int hf::host::MockUart::FlushRxCalls ( ) const
inlinenoexcept

◆ FlushTx()

hf_uart_err_t hf::host::MockUart::FlushTx ( )
overridenoexcept

◆ Initialize()

bool hf::host::MockUart::Initialize ( )
inlineoverridenoexcept

◆ InjectRx() [1/2]

void hf::host::MockUart::InjectRx ( const char *  text)

◆ InjectRx() [2/2]

void hf::host::MockUart::InjectRx ( const std::vector< uint8_t > &  bytes)

◆ Printf()

int hf::host::MockUart::Printf ( const char *  format,
  ... 
)
overridenoexcept

◆ Read()

hf_uart_err_t hf::host::MockUart::Read ( hf_u8_t *  data,
hf_u16_t  length,
hf_u32_t  timeout_ms = 0 
)
overridenoexcept

◆ SetInitializeResult()

void hf::host::MockUart::SetInitializeResult ( bool  ok)
inlinenoexcept

◆ SetOnWrite()

void hf::host::MockUart::SetOnWrite ( OnWrite  on_write)
inline

◆ TxBytes()

const std::vector< uint8_t > & hf::host::MockUart::TxBytes ( ) const
inlinenoexcept

◆ TxWrites()

const std::vector< std::vector< uint8_t > > & hf::host::MockUart::TxWrites ( ) const
inlinenoexcept

◆ Write()

hf_uart_err_t hf::host::MockUart::Write ( const hf_u8_t *  data,
hf_u16_t  length,
hf_u32_t  timeout_ms = 0 
)
overridenoexcept

Member Data Documentation

◆ fail_count_

size_t hf::host::MockUart::fail_count_ {0}
private

◆ fail_error_

hf_uart_err_t hf::host::MockUart::fail_error_ {hf_uart_err_t::UART_ERR_TRANSMISSION_FAILED}
private

◆ flush_rx_calls_

int hf::host::MockUart::flush_rx_calls_ {0}
private

◆ init_result_

bool hf::host::MockUart::init_result_ {true}
private

◆ on_write_

OnWrite hf::host::MockUart::on_write_
private

◆ rx_

std::deque<uint8_t> hf::host::MockUart::rx_
private

◆ tx_

std::vector<uint8_t> hf::host::MockUart::tx_
private

◆ writes_

std::vector<std::vector<uint8_t> > hf::host::MockUart::writes_
private

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