I'm trying to use the UART receive idle timeout (uart_set_rx_timeout() etc.) with RS485. I see the timeout interrupt is enabled in UART registers (I'm using UART1 now) and I added some debug code in the UART interrupt routine so I can see that the TOUT interrupt is actually triggered - and it is. However, when I try to read the incoming data using uart_read_bytes(), the TOUT timeout doesn't return the data to the task - uart_read_bytes() only returns when the buffer becomes full.
Looking at the uart_read_bytes() source, it calls xRingbufferReceive() and I guess xRingbufferReceive() knows nothing about the TOUT interrupt, so it sleeps until the call timeouts or buffer becomes full. I believe the timeout functionality is completely missing from the UART driver. I just cloned the latest repository and this is still the case.
However, the ESP32 RS485 example uses uart_read_bytes() and uart_set_rx_timeout() and gives you the impression that the rx idle timeout has been implemented in the driver.
Am I missing something here or does the driver really lack support for the idle timeout?
ESP32 UART rx idle timeout not working in driver
Re: ESP32 UART rx idle timeout not working in driver
Tout interrupt causes isr to copy data into ringbuffer
Re: ESP32 UART rx idle timeout not working in driver
Thanks for the reply. Yes it does, but my task does not wake up because uart_read_bytes() still blocks although there is data available. I need the task to wake up as soon as tout interrupt occurs so I can process the incoming message. Without this, the tout interrupt is useless.
-
- Posts: 2
- Joined: Sun Jan 31, 2021 6:22 pm
Re: ESP32 UART rx idle timeout not working in driver
I am interested to know if you have found the solution to the problem you described as I have the same problem and I cannot find the solution using ISR rx timeout.Thank you.
Re: ESP32 UART rx idle timeout not working in driver
It's an old question, but here is my solution in case someone else is having this kind of issue.
We do not need to relay on IDF to solve that.
Simple create a FreeRTOS semaphore with xSemaphoreCreateBinary, and take it inside your task using xSemaphoreTake.
Then, from inside the TOUT interrupt give that semaphore using xSemaphoreGiveFromISR.
We do not need to relay on IDF to solve that.
Simple create a FreeRTOS semaphore with xSemaphoreCreateBinary, and take it inside your task using xSemaphoreTake.
Then, from inside the TOUT interrupt give that semaphore using xSemaphoreGiveFromISR.
Who is online
Users browsing this forum: Baidu [Spider] and 63 guests