当前位置:网站首页>RT thread add MSH command
RT thread add MSH command
2022-06-23 09:54:00 【Xiaohui_ Super】
In this paper, the reference 《RT-Thread Programming manual 》https://www.bookstack.cn/read/rtthread-manual-doc/10.6.md
List of articles
How to add a command
In the use of FinSH when , The system provides some useful commands , such as :

In fact, we can add some commands to msh in , The method is as follows :
MSH_CMD_EXPORT(command, desc);
command Is the command to be added ( Function name ),desc It's a description of the command .
A simple test
Here's a simple my_hello Command to test , Add the following code to the project :
void my_hello(void)
{
rt_kprintf("hello world\n");
}
MSH_CMD_EXPORT(my_hello, msh cmd test);
stay msh Type... On the command line help command , You can see our my_hello The command has been added to the command list :

Input my_hello command , Successfully run my_hello() function :

Variable parameter commands
Functions can usually take arguments ,msh Commands can also take parameters , also msh It also supports commands for adding variable parameters , The format of the definition is :
void my_cmd(int argc, char **argv)
Again , Let's write a simple test example :( Remember to open it. MicroLIB)
#include <string.h>
#include <stdio.h>
void led_ctrl(int argc, char **argv)
{
if(argc != 3)
{
rt_kprintf(" Correct format :led_ctrl LEDx ON/OFF\n");
return;
}
if(!strcmp(argv[1] , "LED0"))
{
if(!strcmp(argv[2] , "ON"))
{
rt_kprintf("led0 on!\n");
}
else if(!strcmp(argv[2] , "OFF"))
{
rt_kprintf("led0 off!\n");
}
}
else if(!strcmp(argv[1] , "LED1"))
{
if(!strcmp(argv[2] , "ON"))
{
rt_kprintf("led1 on!\n");
}
else if(!strcmp(argv[2] , "OFF"))
{
rt_kprintf("led1 off!\n");
}
}
}
MSH_CMD_EXPORT(led_ctrl, "LEDx ON/OFF"); // No double quotes ,ON/OFF Will be displayed as 1/0
test result :( Different parameters , The content of operation is also different )

边栏推荐
- Cesium loading orthophoto scheme
- High performance computing center nvme / nvme of nvme of overview
- [网鼎杯 2020 青龙组]AreUSerialz
- Alimentation des animaux de compagnie basée sur stm32
- Gstore weekly gstore source code analysis (IV): black and white list configuration analysis of security mechanism
- Simple understanding of quick sort
- After the uncommitted transactions in the redo log buffer of MySQL InnoDB are persisted to the redo log, what happens if the transaction rollback occurs? How does the redo log handle this transaction
- The second Tencent light · public welfare innovation challenge was launched, and the three competition topics focused on the social value of sustainable development
- Bioinformatics | 基于相互作用神经网络的有效药物-靶标关联预测
- 2022 Gdevops全球敏捷运维峰会-广州站精华回放(附ppt下载)
猜你喜欢
随机推荐
Pizza ordering design - simple factory model
开发者,你对云计算可能有些误解
汇编语言中断及外部设备操作篇--06
sql编写问题,求出当月和上月的环比值
Dr. Sun Jian was commemorated at the CVPR conference. The best student thesis was awarded to Tongji Ali. Lifeifei won the huangxutao Memorial Award
Subscript operator of map
[plugin:vite:import-analysis]Failed to resolve import “@/“ from ““.Does the file exist
UEFI source code learning 4.1 - pcihostbridgedxe
UEFI learning 3.6 - ACPI table on ARM QEMU
The usage of lambda of C
[GXYCTF2019]BabyUpload
Go string comparison
Build a security video monitoring platform using Huawei cloud ECS server
[SUCTF 2019]CheckIn
[GYCTF2020]Blacklist
Developer, you may have some misunderstandings about cloud computing
web--信息泄漏
薄膜干涉数据处理
Three methods to find the limit of univariate function -- lobida's rule and Taylor's formula
Neither rain nor sunshine




![[GXYCTF2019]BabySQli](/img/51/a866a170dd6c0160ce98d553333624.png)
![[网鼎杯 2020 青龙组]AreUSerialz](/img/38/b67f7a42abec1cdaad02f2b7df6546.png)


![[geek challenge 2019] hardsql](/img/73/ebfb410296b8e950c9ac0cf00adc17.png)
