← index #5098PR #14025
Likely Duplicate · medium · value 7.172
QUERY · ISSUE

UART timeout and timeout_char is not working in ESP32

openby WanderGitopened 2019-09-12updated 2021-05-11
port-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.

CANDIDATE · PULL REQUEST

esp32/machine_uart: Apply timeout_char default.

mergedby DvdGiessenopened 2024-03-04updated 2024-03-08
port-esp32

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.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied