差不多了

This commit is contained in:
Robofish 2026-02-04 14:42:14 +08:00
parent e056d5ecc7
commit 8468c53092
2 changed files with 23 additions and 13 deletions

View File

@ -19,12 +19,14 @@
/* Private constants -------------------------------------------------------- */ /* Private constants -------------------------------------------------------- */
static const char *const CLI_WELCOME_MESSAGE = static const char *const CLI_WELCOME_MESSAGE =
"\r\n" "\r\n"
" ______ __ _______ __ \r\n" " __ __ _____ _ _ \r\n"
" | __ \\.-----.| |--.-----.| | |.---.-.-----.| |-.-----.-----.\r\n" " | \\/ | __ \\ | | | | \r\n"
" | <| _ || _ | _ || || _ |__ --|| _| -__| _|\r\n" " | \\ / | |__) |___ | |__ ___ | |_ \r\n"
" |___|__||_____||_____|_____||__|_|__||___._|_____||____|_____|__| \r\n" " | |\\/| | _ // _ \\| '_ \\ / _ \\| __|\r\n"
" -------------------------------------------------------------------\r\n" " | | | | | \\ \\ (_) | |_) | (_) | |_ \r\n"
" FreeRTOS CLI. Type 'help' to view a list of registered commands. \r\n" " |_| |_|_| \\_\\___/|_.__/ \\___/ \\__|\r\n"
" ------------------------------------\r\n"
" Welcome to use MRobot CLI. Type 'help' to view a list of registered commands.\r\n"
"\r\n"; "\r\n";
/* ANSI 转义序列 */ /* ANSI 转义序列 */
@ -97,11 +99,11 @@ static void send_prompt(void);
/* CLI 命令定义表 */ /* CLI 命令定义表 */
static const CLI_Command_Definition_t builtin_commands[] = { static const CLI_Command_Definition_t builtin_commands[] = {
{ "help", "help: 显示所有可用命令\r\n", cmd_help, 0 }, { "help", " --help: 显示所有可用命令\r\n", cmd_help, 0 },
{ "htop", "htop: 动态显示 FreeRTOS 任务状态 (按 'q' 退出)\r\n", cmd_htop, 0 }, { "htop", " --htop: 动态显示 FreeRTOS 任务状态 (按 'q' 退出)\r\n", cmd_htop, 0 },
{ "cd", "cd <path>: 切换目录\r\n", cmd_cd, 1 }, { "cd", " --cd <path>: 切换目录\r\n", cmd_cd, 1 },
{ "ls", "ls: 列出当前目录内容\r\n", cmd_ls, 0 }, { "ls", " --ls: 列出当前目录内容\r\n", cmd_ls, 0 },
{ "show", "show [device] [count]: 显示设备信息\r\n", cmd_show, -1 }, { "show", " --show [device] [count]: 显示设备信息\r\n", cmd_show, -1 },
}; };
#define BUILTIN_CMD_COUNT (sizeof(builtin_commands) / sizeof(builtin_commands[0])) #define BUILTIN_CMD_COUNT (sizeof(builtin_commands) / sizeof(builtin_commands[0]))
@ -124,8 +126,8 @@ static void send_string(const char *str) {
* @brief * @brief
*/ */
static void send_prompt(void) { static void send_prompt(void) {
char prompt[MROBOT_PATH_MAX_LEN + 20]; char prompt[MROBOT_PATH_MAX_LEN + 32];
snprintf(prompt, sizeof(prompt), "root@mrobot:%s$ ", ctx.current_path); snprintf(prompt, sizeof(prompt), MROBOT_USER_NAME "@" MROBOT_HOST_NAME ":%s$ ", ctx.current_path);
send_string(prompt); send_string(prompt);
} }

View File

@ -155,6 +155,14 @@ extern "C" {
#define MROBOT_UART_PORT BSP_UART_VOFA /* 默认 UART 端口 */ #define MROBOT_UART_PORT BSP_UART_VOFA /* 默认 UART 端口 */
#endif #endif
#ifndef MROBOT_USER_NAME
#define MROBOT_USER_NAME "Robofish" /* CLI 用户名 */
#endif
#ifndef MROBOT_HOST_NAME
#define MROBOT_HOST_NAME "balance_infantry" /* CLI 主机名 */
#endif
/* Error codes -------------------------------------------------------------- */ /* Error codes -------------------------------------------------------------- */
typedef enum { typedef enum {
MROBOT_OK = 0, /* 成功 */ MROBOT_OK = 0, /* 成功 */