|
|
|
@ -107,21 +107,28 @@ int console_getline(struct console *console_, char *buf, size_t n) |
|
|
|
|
while (console_getc(&c, console_) == 0) { |
|
|
|
|
switch (c) { |
|
|
|
|
case '\r': |
|
|
|
|
#if CONFIG_USER_ECHO |
|
|
|
|
usart_send_blocking(console->dev, '\r'); |
|
|
|
|
#endif |
|
|
|
|
return 0; |
|
|
|
|
case 10: |
|
|
|
|
case 127: |
|
|
|
|
if (buf < p) { |
|
|
|
|
#if CONFIG_USER_ECHO |
|
|
|
|
usart_send_blocking(console->dev, '\010'); |
|
|
|
|
usart_send_blocking(console->dev, ' '); |
|
|
|
|
usart_send_blocking(console->dev, '\010'); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
--p; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
*p = c; |
|
|
|
|
#if CONFIG_USER_ECHO |
|
|
|
|
usart_send_blocking(console->dev, c); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if (((size_t)p - (size_t)buf) < n) { |
|
|
|
|
++p; |
|
|
|
@ -156,9 +163,11 @@ ssize_t console_read(struct console *console_, char *buf, size_t n) |
|
|
|
|
case 10: |
|
|
|
|
case 127: |
|
|
|
|
if (buf < p) { |
|
|
|
|
#if CONFIG_USER_ECHO |
|
|
|
|
usart_send_blocking(console->dev, '\010'); |
|
|
|
|
usart_send_blocking(console->dev, ' '); |
|
|
|
|
usart_send_blocking(console->dev, '\010'); |
|
|
|
|
#endif |
|
|
|
|
--p; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -170,7 +179,9 @@ ssize_t console_read(struct console *console_, char *buf, size_t n) |
|
|
|
|
goto out; |
|
|
|
|
|
|
|
|
|
*p++ = '\n'; |
|
|
|
|
#if CONFIG_USER_ECHO |
|
|
|
|
usart_send_blocking(console->dev, '\r'); |
|
|
|
|
#endif |
|
|
|
|
console_getc(&c, console_); |
|
|
|
|
goto out; |
|
|
|
|
default: |
|
|
|
@ -178,7 +189,9 @@ ssize_t console_read(struct console *console_, char *buf, size_t n) |
|
|
|
|
goto out; |
|
|
|
|
|
|
|
|
|
*p++ = c; |
|
|
|
|
#if CONFIG_USER_ECHO |
|
|
|
|
usart_send_blocking(console->dev, c); |
|
|
|
|
#endif |
|
|
|
|
console_getc(&c, console_); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|