The WeikaiChannel class is used to implement all the virtual methods of the ESPHome uart::UARTComponent virtual class.
More...
#include <weikai.h>
The WeikaiChannel class is used to implement all the virtual methods of the ESPHome uart::UARTComponent virtual class.
This class is common to the different members of the Weikai components family and therefore avoid code duplication.
Definition at line 296 of file weikai.h.
◆ available()
int esphome::weikai::WeikaiChannel::available |
( |
| ) |
|
|
overridevirtual |
◆ check_channel_down()
bool esphome::weikai::WeikaiChannel::check_channel_down |
( |
| ) |
|
|
protectedvirtual |
check if channel is alive
- Returns
- true if OK
Definition at line 425 of file weikai.cpp.
◆ check_logger_conflict()
void esphome::weikai::WeikaiChannel::check_logger_conflict |
( |
| ) |
|
|
inlineoverrideprotectedvirtual |
◆ dump_channel()
void esphome::weikai::WeikaiChannel::dump_channel |
( |
| ) |
|
|
virtual |
dump channel information
Definition at line 321 of file weikai.cpp.
◆ flush()
void esphome::weikai::WeikaiChannel::flush |
( |
| ) |
|
|
overridevirtual |
Flush the output fifo.
If we refer to Serial.flush() in Arduino it says: ** Waits for the transmission of outgoing serial data to complete. (Prior to Arduino 1.0, this the method was removing any buffered incoming serial data.). ** Therefore we wait until all bytes are gone with a timeout of 100 ms
Implements esphome::uart::UARTComponent.
Definition at line 483 of file weikai.cpp.
◆ get_channel_name()
const char* esphome::weikai::WeikaiChannel::get_channel_name |
( |
| ) |
|
|
inline |
Get the channel name.
- Returns
- the name
Definition at line 315 of file weikai.h.
◆ peek_byte()
bool esphome::weikai::WeikaiChannel::peek_byte |
( |
uint8_t * |
buffer | ) |
|
|
overridevirtual |
Reads the first byte in FIFO without removing it.
- Parameters
-
buffer | pointer to the byte |
- Returns
- true if succeed reading one byte, false if no character available
This method returns the next byte from receiving buffer without removing it from the internal fifo. It returns true if a character is available and has been read, false otherwise.
Implements esphome::uart::UARTComponent.
Definition at line 444 of file weikai.cpp.
◆ read_array()
bool esphome::weikai::WeikaiChannel::read_array |
( |
uint8_t * |
buffer, |
|
|
size_t |
length |
|
) |
| |
|
overridevirtual |
Reads a specified number of bytes from a serial port.
- Parameters
-
buffer | buffer to store the bytes |
length | number of bytes to read |
- Returns
- true if succeed, false otherwise
Typical usage:
Implements esphome::uart::UARTComponent.
Definition at line 458 of file weikai.cpp.
◆ reg()
◆ reset_fifo_()
void esphome::weikai::WeikaiChannel::reset_fifo_ |
( |
| ) |
|
|
protected |
reset the weikai internal FIFO
Definition at line 329 of file weikai.cpp.
◆ rx_in_fifo_()
size_t esphome::weikai::WeikaiChannel::rx_in_fifo_ |
( |
| ) |
|
|
protected |
Returns the number of bytes in the receive fifo.
- Returns
- the number of bytes in the fifo
Definition at line 397 of file weikai.cpp.
◆ set_baudrate_()
void esphome::weikai::WeikaiChannel::set_baudrate_ |
( |
| ) |
|
|
protected |
◆ set_channel()
void esphome::weikai::WeikaiChannel::set_channel |
( |
uint8_t |
channel | ) |
|
|
inline |
Sets the channel number.
- Parameters
-
Definition at line 307 of file weikai.h.
◆ set_channel_name()
void esphome::weikai::WeikaiChannel::set_channel_name |
( |
std::string && |
name | ) |
|
|
inline |
The name as generated by the Python code generator.
- Parameters
-
Definition at line 311 of file weikai.h.
◆ set_line_param_()
void esphome::weikai::WeikaiChannel::set_line_param_ |
( |
| ) |
|
|
protected |
set the line parameters
Definition at line 336 of file weikai.cpp.
◆ set_parent()
void esphome::weikai::WeikaiChannel::set_parent |
( |
WeikaiComponent * |
parent | ) |
|
|
inline |
We belongs to this WeikaiComponent.
- Parameters
-
parent | pointer to the component we belongs to |
Definition at line 300 of file weikai.h.
◆ setup_channel()
void esphome::weikai::WeikaiChannel::setup_channel |
( |
| ) |
|
|
virtual |
◆ tx_fifo_is_not_empty_()
bool esphome::weikai::WeikaiChannel::tx_fifo_is_not_empty_ |
( |
| ) |
|
|
inlineprotected |
test if transmit buffer is not empty in the status register (optimization)
- Returns
- true if not emptygroup test_
Definition at line 382 of file weikai.cpp.
◆ tx_in_fifo_()
size_t esphome::weikai::WeikaiChannel::tx_in_fifo_ |
( |
| ) |
|
|
protected |
Returns the number of bytes in the transmit fifo.
- Returns
- the number of bytes in the fifo
Definition at line 384 of file weikai.cpp.
◆ write_array()
void esphome::weikai::WeikaiChannel::write_array |
( |
const uint8_t * |
buffer, |
|
|
size_t |
length |
|
) |
| |
|
overridevirtual |
Writes a specified number of bytes to a serial port.
- Parameters
-
buffer | pointer to the buffer |
length | number of bytes to write |
This method sends 'length' characters from the buffer to the serial line. Unfortunately (unlike the Arduino equivalent) this method does not return any flag and therefore it is not possible to know if any/all bytes have been transmitted correctly. Another problem is that it is not possible to know ahead of time how many bytes we can safely send as there is no tx_available() method provided! To avoid overrun when using the write method you can use the flush() method to wait until the transmit fifo is empty.
Typical usage could be:
Implements esphome::uart::UARTComponent.
Definition at line 475 of file weikai.cpp.
◆ xfer_fifo_to_buffer_()
size_t esphome::weikai::WeikaiChannel::xfer_fifo_to_buffer_ |
( |
| ) |
|
|
protected |
transfer bytes from the weikai internal FIFO to the buffer (if any)
- Returns
- number of bytes transferred
Definition at line 494 of file weikai.cpp.
◆ channel_
uint8_t esphome::weikai::WeikaiChannel::channel_ |
|
protected |
our Channel number
Definition at line 437 of file weikai.h.
◆ data_
uint8_t esphome::weikai::WeikaiChannel::data_ |
|
protected |
a one byte buffer for register read storage
Definition at line 438 of file weikai.h.
◆ name_
std::string esphome::weikai::WeikaiChannel::name_ |
|
protected |
name of the entity
Definition at line 439 of file weikai.h.
◆ parent_
our WK2168component parent
Definition at line 436 of file weikai.h.
◆ receive_buffer_
the buffer where we store temporarily the bytes received
Definition at line 435 of file weikai.h.
The documentation for this class was generated from the following files:
- /opt/build/esphome/esphome/components/weikai/weikai.h
- /opt/build/esphome/esphome/components/weikai/weikai.cpp