samples: drivers: uart: Read until FIFO empty in echo_bot
The RX ready condition is unspecified with regard to being level or edge triggered, so all available data should then be read once the RX ready condition is detected. This change brings the sample into agreement with the documentation and tests. Signed-off-by: Brett Witherspoon <brett@witherspoon.engineering>
This commit is contained in:
parent
6708b139ab
commit
5ec1b4d1b2
1 changed files with 5 additions and 3 deletions
|
|
@ -36,10 +36,12 @@ void serial_cb(const struct device *dev, void *user_data)
|
|||
return;
|
||||
}
|
||||
|
||||
while (uart_irq_rx_ready(uart_dev)) {
|
||||
|
||||
uart_fifo_read(uart_dev, &c, 1);
|
||||
if (!uart_irq_rx_ready(uart_dev)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* read until FIFO empty */
|
||||
while (uart_fifo_read(uart_dev, &c, 1) == 1) {
|
||||
if ((c == '\n' || c == '\r') && rx_buf_pos > 0) {
|
||||
/* terminate string */
|
||||
rx_buf[rx_buf_pos] = '\0';
|
||||
|
|
|
|||
Loading…
Reference in a new issue