Aruna
|
#include <UART.h>
Public Member Functions | |
UART () | |
UART object to write and read data. More... | |
~UART () | |
size_t | write (uint8_t *data, size_t dataSize) |
Write data to the UART. More... | |
size_t | try_write (uint8_t *data, size_t dataSize) |
Write data to the UART. More... | |
size_t | read (uint8_t *buffer, size_t length) |
read data from the UART. More... | |
size_t | try_read (uint8_t *buffer, size_t length) |
read data from the UART. More... | |
virtual uint32_t | get_read_buffer_length ()=0 |
Get amount of bytes in the read buffer. More... | |
uint32_t | set_baudrate (uint32_t new_baudrate) |
Set baudrate of the UART. More... | |
virtual uint32_t | get_baudrate () |
Get baudrate of UART. More... | |
err_t | set_flowcontrol (flowcontrol_t new_flowcontrol) |
Set software or hardware flowcontrol. More... | |
virtual flowcontrol_t | get_flowcontrol () |
get flowcontrol of UART More... | |
err_t | set_parity (parity_t parity_bit) |
Set parity bit. More... | |
virtual parity_t | get_parity () |
Get parity of UART. More... | |
err_t | set_stop_bit (stop_bit_t stop_bit) |
set stop bit More... | |
virtual stop_bit_t | get_stop_bit () |
get stop bit More... | |
err_t | set_word_length (word_length_t word_length) |
Set UART data bits length. More... | |
virtual word_length_t | get_word_length () |
Set UART data bits length. More... | |
uint32_t | get_speed () override |
Get speed of link (bits per second) More... | |
![]() | |
size_t | transmit (uint8_t *package, size_t package_size) |
directly transmit a package on the link. More... | |
size_t | receive (uint8_t *buffer, size_t buffer_size) |
Read data from the receive buffer. More... | |
bool | is_connected () |
Does the link have an active connection with a client? More... | |
Static Protected Attributes | |
static const uint8_t | XON = 0x11 |
static const uint8_t | XOFF = 0x13 |
Private Member Functions | |
virtual uint32_t | _set_baudrate (uint32_t new_baudrate)=0 |
Set baudrate of the UART. More... | |
virtual err_t | _set_flowcontrol (flowcontrol_t new_flowcontrol)=0 |
Set software or hardware flowcontrol. More... | |
virtual err_t | _set_parity (parity_t parity_bit)=0 |
Set parity bit. More... | |
virtual err_t | _set_stop_bit (stop_bit_t stop_bit)=0 |
set stop bit More... | |
virtual err_t | _set_word_length (word_length_t word_length)=0 |
Set UART data bits length. More... | |
Private Attributes | |
uint32_t | baudrate = 0 |
flowcontrol_t | flowcontrol = flowcontrol_t::NONE |
parity_t | parity = parity_t::NONE |
stop_bit_t | stopBit = stop_bit_t::NONE |
word_length_t | wordLength = word_length_t::NONE |
pthread_mutex_t | write_atomic |
pthread_mutex_t | read_atomic |
Additional Inherited Members | |
![]() | |
err_t | startup_error = err_t::NOT_STARTED |
|
strong |
|
strong |
|
strong |
|
strong |
|
privatepure virtual |
Set baudrate of the UART.
new_baudrate | baudrate to change to. |
Implemented in aruna::driver::POSIX_UART, and aruna::driver::ESP32_UART.
|
privatepure virtual |
Set software or hardware flowcontrol.
new_flowcontrol |
Implemented in aruna::driver::POSIX_UART, and aruna::driver::ESP32_UART.
Set parity bit.
parity_bit | EVEN, UNEVEN or DISABLED |
Implemented in aruna::driver::POSIX_UART, and aruna::driver::ESP32_UART.
|
privatepure virtual |
set stop bit
stop_bit | 1 1.5 or 2 bits |
Implemented in aruna::driver::POSIX_UART, and aruna::driver::ESP32_UART.
|
privatepure virtual |
Set UART data bits length.
word_length | five to eight bits |
Implemented in aruna::driver::POSIX_UART, and aruna::driver::ESP32_UART.
|
virtual |
Get baudrate of UART.
Reimplemented in aruna::driver::ESP32_UART.
Definition at line 34 of file UART.cpp.
|
virtual |
get flowcontrol of UART
Reimplemented in aruna::driver::ESP32_UART.
Definition at line 45 of file UART.cpp.
|
virtual |
|
pure virtual |
Get amount of bytes in the read buffer.
Implemented in aruna::driver::ESP32_UART.
|
overridevirtual |
Get speed of link (bits per second)
Implements aruna::comm::Link.
Definition at line 118 of file UART.cpp.
|
virtual |
|
virtual |
Set UART data bits length.
Reimplemented in aruna::driver::ESP32_UART.
Definition at line 114 of file UART.cpp.
size_t UART::read | ( | uint8_t * | buffer, |
size_t | length | ||
) |
read data from the UART.
buffer | pointer to buffer where UART read data will be written. |
length | amount of bytes to read. |
Definition at line 19 of file UART.cpp.
uint32_t UART::set_baudrate | ( | uint32_t | new_baudrate | ) |
err_t UART::set_flowcontrol | ( | UART::flowcontrol_t | new_flowcontrol | ) |
Set software or hardware flowcontrol.
new_flowcontrol |
Definition at line 38 of file UART.cpp.
err_t UART::set_parity | ( | UART::parity_t | parity_bit | ) |
err_t UART::set_stop_bit | ( | UART::stop_bit_t | stop_bit | ) |
err_t UART::set_word_length | ( | UART::word_length_t | word_length | ) |
Set UART data bits length.
word_length | five to eight bits |
Definition at line 107 of file UART.cpp.
size_t UART::try_read | ( | uint8_t * | buffer, |
size_t | length | ||
) |
read data from the UART.
Return of data os already being read.
buffer | pointer to buffer where UART read data will be written. |
length | amount of bytes to read. |
Definition at line 98 of file UART.cpp.
size_t UART::try_write | ( | uint8_t * | data, |
size_t | dataSize | ||
) |
Write data to the UART.
Return if data is already being written.
data | pointer to array of bytes to be written. |
dataSize | length of data |
Definition at line 89 of file UART.cpp.
size_t UART::write | ( | uint8_t * | data, |
size_t | dataSize | ||
) |
Write data to the UART.
data | pointer to array of bytes to be written. |
dataSize | length of data |
Definition at line 10 of file UART.cpp.
|
private |
|
private |
|
private |
|
private |
|
staticprotected |