From: Segwon Date: Thu, 16 Nov 2017 14:35:59 +0000 (+0900) Subject: uart: flush the uart buffer when setting the flow control X-Git-Tag: accepted/tizen/unified/20171221.071344~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a2ada4a71a7e1a328016b393e5c6f363421468f9;p=platform%2Fcore%2Fapi%2Fperipheral-io.git uart: flush the uart buffer when setting the flow control Change-Id: Ie1c2609a243242ded2ecc1e4411ca07231a784b9 Signed-off-by: Segwon --- diff --git a/include/interface/peripheral_interface_uart.h b/include/interface/peripheral_interface_uart.h index fb44638..75748ce 100644 --- a/include/interface/peripheral_interface_uart.h +++ b/include/interface/peripheral_interface_uart.h @@ -31,9 +31,8 @@ void peripheral_interface_uart_close(peripheral_uart_h uart); * @brief uart_flush() flushes uart buffer. * * @param[in] file_hndl handle of uart_context -* @return On success, 0 is returned. On failure, a negative value is returned. */ -int peripheral_interface_uart_flush(peripheral_uart_h uart); +void peripheral_interface_uart_flush(peripheral_uart_h uart); /** * @brief uart_set_baudrate() sets uart baud rate. diff --git a/src/interface/peripheral_interface_uart.c b/src/interface/peripheral_interface_uart.c index eadef4a..45e0690 100644 --- a/src/interface/peripheral_interface_uart.c +++ b/src/interface/peripheral_interface_uart.c @@ -35,12 +35,9 @@ void peripheral_interface_uart_close(peripheral_uart_h uart) close(uart->fd); } -int peripheral_interface_uart_flush(peripheral_uart_h uart) +void peripheral_interface_uart_flush(peripheral_uart_h uart) { - int ret = tcflush(uart->fd, TCIOFLUSH); - CHECK_ERROR(ret != 0); - - return PERIPHERAL_ERROR_NONE; + tcflush(uart->fd, TCIOFLUSH); } int peripheral_interface_uart_set_baud_rate(peripheral_uart_h uart, peripheral_uart_baud_rate_e baud) @@ -59,6 +56,7 @@ int peripheral_interface_uart_set_baud_rate(peripheral_uart_h uart, peripheral_u tio.c_cc[VTIME] = 0; peripheral_interface_uart_flush(uart); + ret = tcsetattr(uart->fd, TCSANOW, &tio); CHECK_ERROR(ret != 0); @@ -79,6 +77,7 @@ int peripheral_interface_uart_set_byte_size(peripheral_uart_h uart, peripheral_u tio.c_cflag |= (CLOCAL | CREAD); peripheral_interface_uart_flush(uart); + ret = tcsetattr(uart->fd, TCSANOW, &tio); CHECK_ERROR(ret != 0); @@ -111,6 +110,7 @@ int peripheral_interface_uart_set_parity(peripheral_uart_h uart, peripheral_uart } peripheral_interface_uart_flush(uart); + ret = tcsetattr(uart->fd, TCSANOW, &tio); CHECK_ERROR(ret != 0); @@ -139,6 +139,7 @@ int peripheral_interface_uart_set_stop_bits(peripheral_uart_h uart, peripheral_u } peripheral_interface_uart_flush(uart); + ret = tcsetattr(uart->fd, TCSANOW, &tio); CHECK_ERROR(ret != 0); @@ -167,6 +168,8 @@ int peripheral_interface_uart_set_flow_control(peripheral_uart_h uart, periphera else return PERIPHERAL_ERROR_INVALID_PARAMETER; + peripheral_interface_uart_flush(uart); + ret = tcsetattr(uart->fd, TCSANOW, &tio); CHECK_ERROR(ret != 0);