Skip to content

How to add RT-thread msh user command? #10

Closed Answered by onelife
danilliu-sudo asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @danilliu-sudo,

There is an example of user commands, https://github.com/onelife/Arduino_RT-Thread/blob/v0.9.4/examples/FinSH/FinSH.ino:

int led(int argc, char **argv) {
// argc - the number of arguments
// argv[0] - command name, e.g. "led"
// argv[n] - nth argument in the type of char array
rt_uint32_t id;
rt_uint32_t state;
if (argc != 3) {
rt_kprintf("Usage: led <id> <state>\n");
return 1;
}
rt_kprintf("led%s=%s\n", argv[1], argv[2]);
// convert arguments to their specific types
sscanf(argv[1], "%u", &id);
sscanf(argv[2], "%u"

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by onelife
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants