8#if !(defined(__linux__) || defined(__APPLE__))
9#error This HostUartComponent implementation is not supported on this host OS
26speed_t get_baud(
int baud) {
111 ESP_LOGCONFIG(TAG,
"Opening UART port");
114 ESP_LOGE(TAG,
"Unsupported baud rate: %d", this->
baud_rate_);
129 options.c_cflag |= CREAD | CLOCAL;
130 options.c_iflag &= ~(IXOFF | IXANY);
135 options.c_cflag |= CS5;
151 options.c_cflag &= ~PARENB;
172 ESP_LOGCONFIG(TAG,
"UART:");
173 ESP_LOGCONFIG(TAG,
" Port: %s", this->
port_name_.c_str());
175 ESP_LOGCONFIG(TAG,
" Port status: Not opened");
177 ESP_LOGCONFIG(TAG,
" Error: %s", this->
first_error_.c_str());
182 " Port status: opened\n"
204#ifdef USE_UART_DEBUGGER
205 for (
size_t i = 0; i <
len; i++) {
235 size_t length_to_read =
len;
241 if (length_to_read > 0) {
248#ifdef USE_UART_DEBUGGER
249 for (
size_t i = 0; i <
len; i++) {
276 ESP_LOGV(TAG,
" Flushing");
294 bits = (bits & ~(TIOCM_DTR | TIOCM_RTS)) | (dtr ? TIOCM_DTR : 0) | (rts ? TIOCM_RTS : 0);
318 ESP_LOGE(TAG,
"Port error: %s", error.c_str());
void mark_failed()
Mark this component as failed.
bool read_array(uint8_t *data, size_t len) override
bool set_modem_control(bool dtr, bool rts)
Drive DTR/RTS. Returns false when the port is closed or the ioctl fails.
size_t available() override
void write_array(const uint8_t *data, size_t len) override
void update_error_(const std::string &error)
UARTFlushResult flush() override
void check_logger_conflict() override
void dump_config() override
int get_modem_bits_() const
bool peek_byte(uint8_t *data) override
UARTParityOptions parity_
bool check_read_timeout_(size_t len=1)
CallbackManager< void(UARTDirection, uint8_t)> debug_callback_
ESPHOME_LOG_TAG(TAG, "uart.binary_sensor")
@ UART_CONFIG_PARITY_EVEN
@ UART_CONFIG_PARITY_NONE
UARTFlushResult
Result of a flush() call.
@ UART_FLUSH_RESULT_ASSUMED_SUCCESS
Platform cannot report result; success is assumed.
@ UART_FLUSH_RESULT_SUCCESS
Confirmed: all bytes left the TX FIFO.
@ UART_FLUSH_RESULT_FAILED
Confirmed: driver or hardware error.
ESPHOME_ALWAYS_INLINE constexpr void assign_bits(T &value, std::type_identity_t< T > mask, bool on)
Set the bits of mask in value when on is true, clear them otherwise.