← index #8063Issue #5263
Related · high · value 2.004
QUERY · ISSUE

Esp32: Add explicit "wait_tx_done" method to UART

openby mrkeuzopened 2021-12-05updated 2022-05-27
port-esp32

Hello folks,

Faced with issue, I cannot control time when UART TX done from MicroPython.

Use case is next:

  • I've tried to communicate by raw RS485 and I should know when exactly disable TX pin.

Currently, there are couple workarounds (judged by sources and undocumented). In these methods called uart_wait_tx_done():

  • Via init() method. E.g. send bytes and call init(). But if implementation will be changed in future such method stopped worked. Especially this method is very strange to call in the middle of the UART operation.
  • Via sendbreak() method. But also undocumented plus it always sends \x00

Proposal:

  • I think it would be good to add explicit method for waiting UART TX done.
CANDIDATE · ISSUE

ESP32 Uart TX-error using UART.sendbreak()

closedby ImoogDiopened 2019-10-27updated 2019-10-28
port-esp32

I'm using the UART-class to send messages over serial line.
Any message is terminated with the 'BREAK'-signal.
It works so far sending more then 1 char's.
But in that special case sending only 1 char terminated with the UART.sendbreak() call,
the leading char will be overwritten or destructed.
Also the call UART.wait_tx_done(100) before sending the BREAK-signal doesn't help.
Only the call: time.sleep(0.002) before UART.sendbreak() will help a bit.
Used code:
...
uart1 = UART(1, baudrate=9600)
while True:
uart1.write('A')
while uart1.wait_tx_done(100) == False:
pass
# !! sleep required for 1Char- and break-send !!
time.sleep(0.002)
uart1.sendbreak()
time.sleep(1)

Used environment:
ESP32 on Wipy3.0
See attached plots for the resulting streams.
Can you fix this problem in further releases?
uart_tx_failed
uart_tx_OK_withsleep

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied