UART reception variable length message (no pattern)

Lucas.Hutchinson
Posts: 79
Joined: Tue Apr 26, 2016 5:10 am

UART reception variable length message (no pattern)

Postby Lucas.Hutchinson » Wed Dec 19, 2018 3:58 am

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.
Lucas

Lucas.Hutchinson
Posts: 79
Joined: Tue Apr 26, 2016 5:10 am

Re: UART reception variable length message (no pattern)

Postby Lucas.Hutchinson » Sun Jan 06, 2019 7:19 pm

Bumping to see if anyone can help with my question.

Cheers.

ESP_houwenxiang
Posts: 118
Joined: Tue Jun 26, 2018 3:09 am

Re: UART reception variable length message (no pattern)

Postby ESP_houwenxiang » Sun Jan 20, 2019 5:06 am

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 !!
wookooho

Who is online

Users browsing this forum: No registered users and 231 guests