... before writing the data to avoid an infinite loop in case of multiple thread accessing the UART. (#6029)