A replacement for _uart.wait_tx_done in esp32

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
pinazawa
Posts: 8
Joined: Thu Apr 25, 2019 1:13 pm

A replacement for _uart.wait_tx_done in esp32

Post by pinazawa » Thu Jun 20, 2019 8:45 pm

Good Evening,

Many libraries that implement UART comunication in the PyBoard relies on the use of machine.UART.wait_tx_done(ms) to do delays in half or full duplex communications. https://docs.pycom.io/firmwareapi/pycom ... /uart.html

But micropython image for ESP32 (as far as I was able to seach) do not have this method implemented. I also couldn't find the Pycom wait_tx_done(ms) implementation... It seems that it is some sort of C function of the machine lib of their repo.

Am I missing something? How do you guys replaced the wait_tx_done? My application uses RTU modbus, and these delays are killing me :lol:

thanks for the help!

User avatar
untitled
Posts: 24
Joined: Sat Nov 02, 2019 1:44 pm

Re: A replacement for _uart.wait_tx_done in esp32

Post by untitled » Wed Jul 29, 2020 9:14 pm

I have the same issue with uModbus lib.
Did you find a solution?

shaoziyang
Posts: 363
Joined: Sun Apr 17, 2016 1:55 pm

Re: A replacement for _uart.wait_tx_done in esp32

Post by shaoziyang » Thu Jul 30, 2020 2:35 am

You may use pin irq when there is no tx/rx irq function.

User avatar
cederom
Posts: 16
Joined: Tue Oct 26, 2021 1:37 am
Contact:

Re: A replacement for _uart.wait_tx_done in esp32

Post by cederom » Sun Feb 27, 2022 4:00 pm

Hello world :-)

I am using UART on ESP32 with MP 1.18. I am getting errors like:

Code: Select all

E (747225) uart: uart_wait_tx_done(995): uart driver error
E (747235) uart: uart_write_bytes(1119): uart driver error
E (747245) uart: uart_write_bytes(1119): uart driver error
E (747255) uart: uart_write_bytes(1119): uart driver error
E (747265) uart: uart_read_bytes(1154): uart driver error
First bunch of data is going out with no error, on another send such errors occur and UART does not send anything anymore :-(

Update: Okay, so I cannot cal UART.deinit() just do "turn off UART" because it seems to destroy object. Will report as bug.

[1] https://docs.micropython.org/en/latest/ ... ART.deinit
--
CeDeROM, SQ7MHZ, https://www.tomek.cedro.info

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: A replacement for _uart.wait_tx_done in esp32

Post by Roberthh » Sun Feb 27, 2022 4:33 pm

uart.init() runs a call to uart_wait_tx_done() when it starts. Unfortunately, not all arguments have a default value that cause a setting to be ignored. So if you changed timeout, timeout_char, invert or flow, you have to repeat the settings in an init() call.

User avatar
cederom
Posts: 16
Joined: Tue Oct 26, 2021 1:37 am
Contact:

Re: A replacement for _uart.wait_tx_done in esp32

Post by cederom » Sun Feb 27, 2022 5:50 pm

Thank you :-) All clear now, UART.deinit() destroys the object, it needs to be re-created again before UART.init(), but UART.init() can be called multiple times to change settings :-)

Here is the GH issue: https://github.com/micropython/micropython/issues/8362

Documentation needs an update with clarification :-)

Have a good day! :-)
--
CeDeROM, SQ7MHZ, https://www.tomek.cedro.info

Post Reply