UART timeout and timeout_char is not working in ESP32
Hi,
I noticed that UART timeout_char is not working. Regardless of the value of this parameter, UART always waits for around 8x the time of a character to identify that communication has ended.
With the help of a forum contributor, we were able to locate and fix the problem.
In the machine_uart.c we add the following command to line 208:
uart_set_rx_timeout(self->uart_num, self->timeout_char);
==================================================
Now that code snippet looked like this:
// set timeout_char
// make sure it is at least as long as a whole character (13 bits to be safe)
self->timeout_char = args[ARG_timeout_char].u_int;
uint32_t min_timeout_char = 13000 / baudrate + 1;
if (self->timeout_char < min_timeout_char) {
self->timeout_char = min_timeout_char;
}
uart_set_rx_timeout(self->uart_num, self->timeout_char);
==================================================
I don't know if timeouts have been disabled for a specific reason, but I would like to report that this minor fix resolves the issue, at least for timeout_char.
esp32/machine_uart: Apply timeout_char default.
If the timeout_char parameter is not given, we should still configure the UART to ensure the UART is always initialized consistently. So the default of 0get applied correctly, or if for example the baud rate was changed the char timeout isn't still based on the old baud rate causing weird behaviour, etc.