同步操作将从 OpenHarmony/docs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
You can perform the following operations to add shell commands:
Include the following header files:
#include "shell.h"
#include "shcmd.h"
Register commands. You can register commands either statically or dynamically when the system is running. In most cases, static registration is widely used by common system commands, and dynamic registration is widely used by user commands.
Static registration:
Register a command using a macro.
The prototype of the macro is as follows:
SHELLCMD_ENTRY(l, cmdType, cmdKey, paraNum, cmdHook)
Table 1 Parameters of the SHELLCMD_ENTRY macro
For example:
SHELLCMD_ENTRY(ls_shellcmd, CMD_TYPE_EX, "ls", XARGS, (CMD_CBK_FUNC)osShellCmdLs)
Add the required options to the build/mk/liteos_tables_ldflags.mk file.
For example, when registering the ls command, add -uls_shellcmd to the build/mk/liteos_tables_ldflags.mk file. -u is followed by the first parameter of SHELLCMD_ENTRY.
Dynamic registration:
The prototype of the function to register is as follows:
UINT32 osCmdReg(CmdT ype cmdType, CHAR *cmdKey, UINT32 paraNum, CmdCallBackFunc cmdProc)
Table 2 Parameters of UINT32 osCmdReg
For example:
osCmdReg(CMD_TYPE_EX, "ls", XARGS, (CMD_CBK_FUNC)osShellCmdLs)
NOTE: The command keyword must be unique. Specifically, two different commands cannot share the same command keyword. Otherwise, only one command is executed. When executing user commands sharing the same keyword, the shell executes only the first command in the help commands.
Use the following function prototype to add built-in commands:
UINT32 osShellCmdLs(UINT32 argc, CHAR **argv)
Table 3 Parameters of osShellCmdLs
Indicates a pointer array, where each element points to a string. You can determine whether to pass the command keyword to the registration function by specifying the command type. |
Enter the shell command in either of the following methods:
Enter the shell command in the serial port tool.
Enter the shell command in the Telnet tool. For details, see telnet.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。