summaryrefslogtreecommitdiff
path: root/common/console.c
diff options
context:
space:
mode:
authorVic Yang <victoryang@google.com>2012-02-01 17:25:01 +0800
committerVic Yang <victoryang@google.com>2012-02-07 10:23:59 +0800
commit730f099c83b67861a269560e2bb5da1bd6bee503 (patch)
treef31cbcfcc2eeac7f387e7c11a53aa3960c28c28c /common/console.c
parentd3e1de758cfa3a7dd990f0fb63eddbb1ae870418 (diff)
downloadchrome-ec-730f099c83b67861a269560e2bb5da1bd6bee503.tar.gz
Handle up/down arrow keys for UART console.
Record commands used previously and use up/down arrow key to navigate in the command history. Also removed the command '.' of repeating last command as we can use up arrow key now. Also changed the behaviour of uart_write_char() to be blocking on transmit FIFO full, so that we do not lose echoed character and do not need to flush. BUG=chrome-os-partner:7815 TEST=Type 'help' and enter. Then type 'aaaa' and up arrow key, should show 'help', and pressing enter prints help. Type 'hellp' and enter. Then type 'aaaaaa' and up arrow key, should show 'hellp'. Should be able to use left/right arrow key and backspace to correct it to 'help', and pressing enter prints help. Type 'help' and enter. Then type 'aaa', up arrow key, and down arrow key. Should show 'aaa'. Change-Id: I65c615d61bf63acb31bea329aa91a3202d4db0ad
Diffstat (limited to 'common/console.c')
-rw-r--r--common/console.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/common/console.c b/common/console.c
index eda49855a3..130b7e4ef1 100644
--- a/common/console.c
+++ b/common/console.c
@@ -103,7 +103,6 @@ static int handle_command(char *input)
}
-static char last_input[80];
static char input_buf[80];
/* handle a console command */
@@ -118,12 +117,6 @@ void console_process(void)
while (uart_peek('\n') >= 0) {
uart_gets(input_buf, sizeof(input_buf));
- /* "." repeats the last command, if any */
- if (!strcasecmp(input_buf, ".\n"))
- strzcpy(input_buf, last_input, sizeof(input_buf));
- else if (!isspace(*input_buf))
- strzcpy(last_input, input_buf, sizeof(last_input));
-
rv = handle_command(input_buf);
if (rv != EC_SUCCESS)
uart_printf("Command returned error %d\n", rv);
@@ -177,7 +170,7 @@ static int command_help(int argc, char **argv)
prev = next;
}
- uart_puts("\n'.' repeats the last command.\n");
+ uart_puts("\n");
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(help, command_help);
@@ -187,7 +180,6 @@ DECLARE_CONSOLE_COMMAND(help, command_help);
int console_init(void)
{
- *last_input = '\0';
*input_buf = '\0';
uart_set_console_mode(1);
uart_printf("Console is enabled; type HELP for help.\n");