8#if !(defined(__linux__) || defined(__APPLE__))
9#error This HostUartComponent implementation is not supported on this host OS
26speed_t get_baud(
int baud) {
102static const char *
const TAG =
"uart.host";
112 ESP_LOGCONFIG(TAG,
"Opening UART port");
115 ESP_LOGE(TAG,
"Unsupported baud rate: %d", this->
baud_rate_);
129 options.c_cflag |= CREAD | CLOCAL;
135 options.c_iflag &= ~(IXON | IXOFF | IXANY);
136 options.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL);
143 options.c_cflag |= CS5;
159 options.c_cflag &= ~PARENB;
172 options.c_cflag |= CSTOPB;
182 ESP_LOGCONFIG(TAG,
"UART:");
183 ESP_LOGCONFIG(TAG,
" Port: %s", this->
port_name_.c_str());
185 ESP_LOGCONFIG(TAG,
" Port status: Not opened");
187 ESP_LOGCONFIG(TAG,
" Error: %s", this->
first_error_.c_str());
192 " Port status: opened\n"
210 if (written !=
len) {
214#ifdef USE_UART_DEBUGGER
215 for (
size_t i = 0; i <
len; i++) {
246 uint8_t *data_ptr = data;
247 size_t length_to_read =
len;
254 if (length_to_read > 0) {
261#ifdef USE_UART_DEBUGGER
262 for (
size_t i = 0; i <
len; i++) {
289 ESP_LOGV(TAG,
" Flushing");
296 ESP_LOGE(TAG,
"Port error: %s", error.c_str());
virtual void mark_failed()
Mark this component as failed.
bool read_array(uint8_t *data, size_t len) override
void write_array(const uint8_t *data, size_t len) override
void update_error_(const std::string &error)
void check_logger_conflict() override
void dump_config() override
virtual ~HostUartComponent()
bool peek_byte(uint8_t *data) override
UARTParityOptions parity_
bool check_read_timeout_(size_t len=1)
CallbackManager< void(UARTDirection, uint8_t)> debug_callback_
@ UART_CONFIG_PARITY_EVEN
@ UART_CONFIG_PARITY_NONE
Providing packet encoding functions for exchanging data with a remote host.