Page 1 of 1

A replacement for _uart.wait_tx_done in esp32

Posted: Thu Jun 20, 2019 8:45 pm
by pinazawa
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!

Re: A replacement for _uart.wait_tx_done in esp32

Posted: Wed Jul 29, 2020 9:14 pm
by untitled
I have the same issue with uModbus lib.
Did you find a solution?

Re: A replacement for _uart.wait_tx_done in esp32

Posted: Thu Jul 30, 2020 2:35 am
by shaoziyang
You may use pin irq when there is no tx/rx irq function.

Re: A replacement for _uart.wait_tx_done in esp32

Posted: Sun Feb 27, 2022 4:00 pm
by cederom
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

Re: A replacement for _uart.wait_tx_done in esp32

Posted: Sun Feb 27, 2022 4:33 pm
by Roberthh
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.

Re: A replacement for _uart.wait_tx_done in esp32

Posted: Sun Feb 27, 2022 5:50 pm
by cederom
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! :-)