Skip to content

Commit

Permalink
drivers: console: uart_console.c: add LF detection
Browse files Browse the repository at this point in the history
Add case \n, so that new line from unix or linux host can be detected.

Signed-off-by: Shun Jing Goh <shun.jing.goh@gmail.com>
  • Loading branch information
sj-goh committed Jan 29, 2023
1 parent ef9d5bb commit ccd4b4a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/console/uart_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ static void uart_console_isr(const struct device *unused, void *user_data)
{
ARG_UNUSED(unused);
ARG_UNUSED(user_data);
static uint8_t last_char = '\0';

while (uart_irq_update(uart_console_dev) &&
uart_irq_is_pending(uart_console_dev)) {
Expand Down Expand Up @@ -501,6 +502,11 @@ static void uart_console_isr(const struct device *unused, void *user_data)
case ESC:
atomic_set_bit(&esc_state, ESC_ESC);
break;
case '\n':
if (last_char == '\r') {
/* break to avoid double line*/
break;
}
case '\r':
cmd->line[cur + end] = '\0';
uart_poll_out(uart_console_dev, '\r');
Expand All @@ -519,6 +525,7 @@ static void uart_console_isr(const struct device *unused, void *user_data)
break;
}

last_char = byte;
continue;
}

Expand Down

0 comments on commit ccd4b4a

Please sign in to comment.