QUERY · ISSUE
esp8266: Necessity for UART flush
port-esp8266
This is rather recommendation than issue. The code below sends a string message from UART1 and is supposed to pull the output pin LOW :
mypin.on()
uart1.write("a long sentence")
mypin.off()
when I checked the signal (part tx and output) with logic analyzer, I saw that pin is pulled low long before the uart transmission has been completed. A function like uart.flash() which checks the relevant uart status bits for completion of the transmission would be very handy.
CANDIDATE · PULL REQUEST
ports: Implement uart.flush() and uart.txdone().
ports
uart.flush waits until all data has been sent.
rc = uart.txdone() tells, whether all data has been sent or not data transfer is ongoing.
rc is True in that case.
Supported ports and notes
- rp2: uart.flush() returns while the last byte is transferred. uart.txdone() may also return
Truein that state. - esp8266: uart.flush() returns while the last byte is transferred. uart.txdone() may also return
Truein that state. - esp32
- stm32: uart.flush() and uart.txdone() are empty functions, because uart.write() itself does not return before all data has been sent.
- mimxrt
- nrf: For the nrf port uart.flush() and empty functions are dummy function as well. uart.flush() returns while the last byte is transferred. uart.txdone() may also return
Truein that state. - cc3200
- samd: Implemented and kept in the 2nd level commit queue.