IO::Serial Class Reference

Wrapper class for the UART driver. More...

#include <Serial.h>

Classes

struct  Config
 

Public Member Functions

virtual ~Serial ()
 
ErrorCode open (uint8_t uart_nr, uint8_t txPin=UART_PIN_DEFAULT, uint8_t rxPin=UART_PIN_DEFAULT)
 Initialise the serial port with a default configuration. More...
 
void close ()
 Close the port. More...
 
bool resizeBuffers (size_t rxSize, size_t txSize)
 Set required buffer sizes. More...
 
void setCallback (smg_uart_callback_t callback, void *param)
 
void setBreak (bool state)
 
size_t available () const
 
size_t read (void *buffer, size_t size)
 
size_t write (const void *data, size_t len)
 
void swap (uint8_t txPin=1)
 
void clear (smg_uart_mode_t mode=UART_FULL)
 
const ConfiggetConfig () const
 
void setConfig (const Config &cfg)
 

Detailed Description

Wrapper class for the UART driver.

RS485 requires efficient burst transfer access to the serial hardware, so uses the UART driver directly.

Constructor & Destructor Documentation

◆ ~Serial()

virtual IO::Serial::~Serial ( )
inlinevirtual

Member Function Documentation

◆ available()

size_t IO::Serial::available ( ) const
inline

◆ clear()

void IO::Serial::clear ( smg_uart_mode_t  mode = UART_FULL)
inline

◆ close()

void IO::Serial::close ( )

Close the port.

◆ getConfig()

const Config& IO::Serial::getConfig ( ) const
inline

◆ open()

ErrorCode IO::Serial::open ( uint8_t  uart_nr,
uint8_t  txPin = UART_PIN_DEFAULT,
uint8_t  rxPin = UART_PIN_DEFAULT 
)

Initialise the serial port with a default configuration.

◆ read()

size_t IO::Serial::read ( void *  buffer,
size_t  size 
)
inline

◆ resizeBuffers()

bool IO::Serial::resizeBuffers ( size_t  rxSize,
size_t  txSize 
)

Set required buffer sizes.

Serial buffers are expanded if required, but not reduced.

Parameters
rxSize
txSize
Return values
booltrue on success

◆ setBreak()

void IO::Serial::setBreak ( bool  state)
inline

◆ setCallback()

void IO::Serial::setCallback ( smg_uart_callback_t  callback,
void *  param 
)
inline

◆ setConfig()

void IO::Serial::setConfig ( const Config cfg)

◆ swap()

void IO::Serial::swap ( uint8_t  txPin = 1)
inline

◆ write()

size_t IO::Serial::write ( const void *  data,
size_t  len 
)
inline

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