uart_commands.c: improved UART error handling

This commit is contained in:
Christian Kroll 2014-08-31 23:31:42 +02:00
parent 82c44aec65
commit 09d7d80674
1 changed files with 3 additions and 12 deletions

View File

@ -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;
} }
} }