From 2f1af492eeb1106d8af0cfbdbafdf3fbfe9f822d Mon Sep 17 00:00:00 2001 From: Tomasz Bursztyka Date: Tue, 24 Jan 2017 10:08:08 +0100 Subject: [PATCH] console/shell: Switch to generic console input Let's use the generic console input type now. This will be useful for other console input drivers such as telnet. Change-Id: I787a1e9d86481d5f8c4803453726d9042a89dea4 Signed-off-by: Tomasz Bursztyka --- drivers/console/uart_console.c | 3 ++- include/drivers/console/uart_console.h | 6 ------ subsys/shell/shell.c | 13 ++++++++++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/console/uart_console.c b/drivers/console/uart_console.c index 958e48bf73..73b11a4304 100644 --- a/drivers/console/uart_console.c +++ b/drivers/console/uart_console.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -340,7 +341,7 @@ void uart_console_isr(struct device *unused) while (uart_irq_update(uart_console_dev) && uart_irq_is_pending(uart_console_dev)) { - static struct uart_console_input *cmd; + static struct console_input *cmd; uint8_t byte; int rx; diff --git a/include/drivers/console/uart_console.h b/include/drivers/console/uart_console.h index 7f0ef53580..8277e7e195 100644 --- a/include/drivers/console/uart_console.h +++ b/include/drivers/console/uart_console.h @@ -15,12 +15,6 @@ extern "C" { #include -#define MAX_LINE_LEN 256 -struct uart_console_input { - int _unused; - char line[MAX_LINE_LEN]; -}; - /** @brief Register uart input processing * * Input processing is started when string is typed in the console. diff --git a/subsys/shell/shell.c b/subsys/shell/shell.c index 4dbcb861e7..2301583b39 100644 --- a/subsys/shell/shell.c +++ b/subsys/shell/shell.c @@ -14,10 +14,14 @@ #include #include -#include +#include #include #include +#ifdef CONFIG_UART_CONSOLE +#include +#endif + #include #define ARGC_MAX 10 @@ -40,7 +44,7 @@ static int default_module = -1; static char __stack stack[STACKSIZE]; #define MAX_CMD_QUEUED 3 -static struct uart_console_input buf[MAX_CMD_QUEUED]; +static struct console_input buf[MAX_CMD_QUEUED]; static struct k_fifo avail_queue; static struct k_fifo cmds_queue; @@ -329,7 +333,7 @@ static void shell(void *p1, void *p2, void *p3) ARG_UNUSED(p3); while (1) { - struct uart_console_input *cmd; + struct console_input *cmd; shell_cmd_function_t cb; printk("%s", get_prompt()); @@ -505,6 +509,7 @@ static uint8_t completion(char *line, uint8_t len) return common_chars - command_len + space; } + void shell_init(const char *str) { k_fifo_init(&cmds_queue); @@ -518,7 +523,9 @@ void shell_init(const char *str) K_PRIO_COOP(7), 0, K_NO_WAIT); /* Register serial console handler */ +#ifdef CONFIG_UART_CONSOLE uart_register_input(&avail_queue, &cmds_queue, completion); +#endif } /** @brief Optionally register an app default cmd handler.