Browse Source

uart_commands.c: improved UART error handling

feature/2015
Christian Kroll 10 years ago
parent
commit
09d7d80674
  1. 15
      src/uart/uart_commands.c

15
src/uart/uart_commands.c

@ -240,8 +240,7 @@ static bool uartcmd_read_until_enter(void) {
while (g_rx_index < (UART_BUFFER_SIZE - 1)) { while (g_rx_index < (UART_BUFFER_SIZE - 1)) {
int uart_result = uart_getc(); int uart_result = uart_getc();
switch (uart_result & 0xFF00u) { if (uart_result < 0x100u) {
case 0:
switch ((char)uart_result) { switch ((char)uart_result) {
case '\r': // carriage return case '\r': // carriage return
case '\n': // line feed case '\n': // line feed
@ -264,20 +263,12 @@ static bool uartcmd_read_until_enter(void) {
uart_putc(uart_result); uart_putc(uart_result);
break; break;
} }
break; } else if ((uart_result & 0xFF00u) != UART_NO_DATA) {
case UART_FRAME_ERROR:
case UART_OVERRUN_ERROR:
case UART_PARITY_ERROR:
case UART_BUFFER_OVERFLOW:
uartcmd_clear_buffer(); uartcmd_clear_buffer();
uart_puts_p(UART_STR_UART_ERR); uart_puts_p(UART_STR_UART_ERR);
uart_puts_p(UART_STR_PROMPT); uart_puts_p(UART_STR_PROMPT);
break; break;
} else {
case UART_NO_DATA:
default:
return false;
break; break;
} }
} }

Loading…
Cancel
Save