Data loss when sending to UART.

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
prem111
Posts: 127
Joined: Sun Feb 23, 2020 3:18 pm

Data loss when sending to UART.

Post by prem111 » Sat Apr 30, 2022 11:27 am

Hello, when quickly sending to uart .write (several at a time) some data is lost, how can I prevent this?

baudrate: 115200, rxbuf = 250, txbuf = 250

If it keeps 0.15ms interval it is OK. Reducing the baudrate to 9600 does not solve the problem.

micropython: 1.14 (esp32)

Thanks for help.
Last edited by prem111 on Sat Apr 30, 2022 4:07 pm, edited 2 times in total.

tepalia02
Posts: 99
Joined: Mon Mar 21, 2022 5:13 am

Re: Data loss when sending to UART.

Post by tepalia02 » Sat Apr 30, 2022 1:34 pm

You can get some solutions from this old thread: viewtopic.php?t=6244

prem111
Posts: 127
Joined: Sun Feb 23, 2020 3:18 pm

Re: Data loss when sending to UART.

Post by prem111 » Sat Apr 30, 2022 3:58 pm

tepalia02 wrote:
Sat Apr 30, 2022 1:34 pm
You can get some solutions from this old thread: viewtopic.php?t=6244
Changing the rxbuf does not help.

tepalia02
Posts: 99
Joined: Mon Mar 21, 2022 5:13 am

Re: Data loss when sending to UART.

Post by tepalia02 » Sun May 01, 2022 7:49 am

Have you tried any other baud rate? For example, 9600?

prem111
Posts: 127
Joined: Sun Feb 23, 2020 3:18 pm

Re: Data loss when sending to UART.

Post by prem111 » Sun May 01, 2022 8:44 am

tepalia02 wrote:
Sun May 01, 2022 7:49 am
Have you tried any other baud rate? For example, 9600?
It doesn't help, and it even gets worse. I actually located the problem, unfortunately I do not know the solution. The problem with reading from UART is when I use uart.write at the same time (another task in uasyncio - I'm using StreamWriter and StremReader). The solution would be to block .write for .read time, but I don't know how to do that ...

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Data loss when sending to UART.

Post by pythoncoder » Sun May 01, 2022 9:58 am

It would help if you showed us a code sample that exhibits the problem, and also tell us what hardware you're using. I've used StreamWriter and StreamReader quite extensively, including concurrent reading and writing, and not seen this effect. If it can be demonstrated it's a bug that we should report.
Peter Hinch
Index to my micropython libraries.

prem111
Posts: 127
Joined: Sun Feb 23, 2020 3:18 pm

Re: Data loss when sending to UART.

Post by prem111 » Mon May 02, 2022 11:02 am

pythoncoder wrote:
Sun May 01, 2022 9:58 am
It would help if you showed us a code sample that exhibits the problem, and also tell us what hardware you're using. I've used StreamWriter and StreamReader quite extensively, including concurrent reading and writing, and not seen this effect. If it can be demonstrated it's a bug that we should report.
Sorry, it was my mistake, uart async is ok.

Post Reply