Just a small doubt that hit me recently.
I have an ESP32 project where I answer to a custom communication protocol on UART0. I have a task receiving interrupts when there is data to read that elaborates the requests and in turn sends (through a message queue) valid messages to a second task. The second task then answer those requests, eventually by writing to the UART in turn.
Is is safe to have a task reading the uart while another one writes it (concurrently)? Rx and Tx lines are separated, and up until now there was no problem, but you never know. Should I use a semaphore or have both communication directions in a single thread?
Is it safe to read and write UART from different tasks?
-
- Posts: 47
- Joined: Thu Dec 20, 2018 9:47 am
Re: Is it safe to read and write UART from different tasks?
There's an esp-idf example called "UART Asynchronous Example with Separate Receive and Transfer Tasks" at https://github.com/espressif/esp-idf/tr ... _rxtxtasks so it looks like it can be done.
Re: Is it safe to read and write UART from different tasks?
Looking just at uart.c, apparently YES, but anyone can really confirm if all uart tx are safe?
Who is online
Users browsing this forum: Bing [Bot], MicroController and 207 guests