Page 1 of 1

UART reception variable length message (no pattern)

Posted: Wed Dec 19, 2018 3:58 am
by Lucas.Hutchinson
Hi All,

I have a currently working uart messaging protocol that sends variable lenght messages between the esp32 and another microcontroller.

I am wanting to change from the current method, which keeps the uart task very busy with small vtask_delay's, to an interrupt based reception. This is to prevent the uart task from keeping the ESP32 awake when light sleep is enabled.

I have seen in the uart peripheral driver there is the UART_RXFIFO_TOUT_INT interrupt. It looks like exactly what i am looking for.
The protocol sends a message between 8 and 520 bytes with gaps between messages. The gap is 5ms maximum when running at 2Mbaud. The messages are guarunteed to be sent with no gaps between bytes.

This timeout seems to be ideal, as from what i can read in the doccumemntation the interrupt will fire if there is a period of time where no new bytes have been recieved.

I have had a look into the default uart driver with the ring buffer etc, but i couldn't find any real information on how to setup or use this feature.
I can see there is the function uart_set_rx_timeout to set the timeout in bytes. and that there is a uart_enable_rx_intr function which enables both the RX_FULL and RX_TIMEOUT interrupts, both of which seem to be enabled when using the default uart driver.

Is it as simple as setting up an additional interrupt handler to what is setup in uart_driver_install, and checking if this flag has been set?

Thanks in advance.

Re: UART reception variable length message (no pattern)

Posted: Sun Jan 06, 2019 7:19 pm
by Lucas.Hutchinson
Bumping to see if anyone can help with my question.


Re: UART reception variable length message (no pattern)

Posted: Sun Jan 20, 2019 5:06 am
by ESP_houwenxiang
Hi Lucas.Hutchinson
The UART driver is for general purpose, so, some situations are not considered. If you want to know if the idle interrupt is happened, you can send an event in the interrupt to notify the task.

thanks !!