提交 38659807 编写于 作者: J Jinliang Li

cli: add exit command to exit a console (#1371)

Add exit command, which can exit another console except for uart, e.g.
adb console/telnet console.

Export some apis that are needed by multi-console.
Signed-off-by: NJinliang Li <ljl150821@alibaba-inc.com>
上级 50decede
......@@ -46,6 +46,7 @@ source_file:
- src/iobox/pwd.c ? <CLI_IOBOX_ENABLE>
- src/iobox/hexdump.c ? <CLI_IOBOX_ENABLE>
- src/iobox/path_helper.c ? <CLI_IOBOX_ENABLE>
- src/iobox/exit.c ? <CLI_IOBOX_ENABLE>
def_config:
AOS_COMP_CLI: 1
......
......@@ -75,7 +75,7 @@ extern uint32_t vfs_get_match_dev_node(const char *name, char *match_name);
int32_t cli_va_printf(const char *fmt, va_list va);
int32_t cli_printf(const char *fmt, ...);
static inline void cli_prefix_print(void)
void cli_prefix_print(void)
{
#if CLI_IOBOX_ENABLE
char _buf[PATH_MAX] = {0};
......@@ -716,7 +716,7 @@ static void cli_down_history(char *inaddr)
* Ctrl K Delete to the end of the line
* Ctrl U Delete the entire line
*/
static int32_t cli_get_input(char *inbuf, uint32_t size)
int32_t cli_get_input(char *inbuf, uint32_t size)
{
char c;
uint32_t i;
......
......@@ -40,6 +40,16 @@ void cli_task_exit(void);
*/
int32_t cli_getchar(char *inbuf);
/**
* @brief Output character to cli
*
* @param[out] ch the character to be outputed
*
* @return the number of the character
*
*/
int32_t cli_putchar(char ch);
/**
* @brief Put the message via uart
*
......
......@@ -244,7 +244,7 @@ static inline void cli_console_shared_sem_post(aos_sem_t *sem)
aos_sem_signal(sem);
}
char *cli_task_get_console(void *task_handle)
void *cli_task_get_console(void *task_handle)
{
ktask_t *task = (ktask_t *)task_handle;
void *cli_console = NULL;
......
......@@ -103,7 +103,7 @@ void check_console_task_exit(void);
int cli_task_set_console(void *task_handle, void *console);
char *cli_task_get_console(void *task_handle);
void *cli_task_get_console(void *task_handle);
void cli_console_remove_task_list_node(cli_console *console, void *task);
......
/*
* Copyright (C) 2022 Alibaba Group Holding Limited
*/
#include <cli_api.h>
#include <cli_console.h>
static int exit_main(int argc, char **argv)
{
cli_console *cur_console = cli_task_get_console(krhino_cur_task_get());
cli_console_set_exit_flag(cur_console);
return 0;
}
ALIOS_CLI_CMD_REGISTER(exit_main, exit, exit the console);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册