ESP8266: protects setting UART HW flow control with a mutex

pull/9473/head
Veijo Pesonen 2019-02-06 15:39:03 +02:00
parent 108ec44b66
commit 706dd39569
1 changed files with 6 additions and 0 deletions

View File

@ -187,6 +187,7 @@ bool ESP8266::start_uart_hw_flow_ctrl(void)
bool done = true; bool done = true;
#if DEVICE_SERIAL_FC #if DEVICE_SERIAL_FC
_smutex.lock();
if (_serial_rts != NC && _serial_cts != NC) { if (_serial_rts != NC && _serial_cts != NC) {
// Start ESP8266's flow control // Start ESP8266's flow control
done = _parser.send("AT+UART_CUR=%u,8,1,0,3", ESP8266_DEFAULT_BAUD_RATE) done = _parser.send("AT+UART_CUR=%u,8,1,0,3", ESP8266_DEFAULT_BAUD_RATE)
@ -213,6 +214,11 @@ bool ESP8266::start_uart_hw_flow_ctrl(void)
_serial.set_flow_control(SerialBase::CTS, NC, _serial_cts); _serial.set_flow_control(SerialBase::CTS, NC, _serial_cts);
} }
} }
_smutex.unlock();
if (!done) {
tr_debug("Enable UART HW flow control: FAIL");
}
#else #else
if (_serial_rts != NC || _serial_cts != NC) { if (_serial_rts != NC || _serial_cts != NC) {
done = false; done = false;