diff options
author | Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com> | 2017-01-24 10:08:08 +0100 |
---|---|---|
committer | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2017-01-27 12:35:53 +0200 |
commit | 2f1af492eeb1106d8af0cfbdbafdf3fbfe9f822d (patch) | |
tree | 397447e9c45e7405926cca77546438b0973dfb5f | |
parent | 3e65158936b3acd48c7df58b3ef76247778c9f2b (diff) |
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 <tomasz.bursztyka@linux.intel.com>
-rw-r--r-- | drivers/console/uart_console.c | 3 | ||||
-rw-r--r-- | include/drivers/console/uart_console.h | 6 | ||||
-rw-r--r-- | 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 958e48bf7..73b11a430 100644 --- a/drivers/console/uart_console.c +++ b/drivers/console/uart_console.c @@ -26,6 +26,7 @@ #include <board.h> #include <uart.h> +#include <console/console.h> #include <console/uart_console.h> #include <toolchain.h> #include <sections.h> @@ -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 7f0ef5358..8277e7e19 100644 --- a/include/drivers/console/uart_console.h +++ b/include/drivers/console/uart_console.h @@ -15,12 +15,6 @@ extern "C" { #include <kernel.h> -#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 4dbcb861e..2301583b3 100644 --- a/subsys/shell/shell.c +++ b/subsys/shell/shell.c @@ -14,10 +14,14 @@ #include <stdio.h> #include <string.h> -#include <console/uart_console.h> +#include <console/console.h> #include <misc/printk.h> #include <misc/util.h> +#ifdef CONFIG_UART_CONSOLE +#include <console/uart_console.h> +#endif + #include <shell/shell.h> #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. |