Adding Custom CLI commands to OpenThread CLI

206 views
Skip to first unread message

Nikhil Komalan

unread,
Sep 1, 2021, 2:40:31 AM9/1/21
to openthread-users
Hello,

I would like to know how can i add my custom CLI commands to the Open thread CLI. I have referred the following https://openthread.io/reference/group/api-cli to create my custom CLI command but without any success.

Is there any demo example available or code snippet available showing how to add the custom CLI command ?

Jonathan Hui

unread,
Sep 1, 2021, 2:52:22 AM9/1/21
to Nikhil Komalan, openthread-users
You can find an example use of otCliSetUserCommands() in src/posix/main.c.

--
Jonathan Hui


--
You received this message because you are subscribed to the Google Groups "openthread-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openthread-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openthread-users/7d8bd842-2e2e-49fa-86f1-4b71d3498956n%40googlegroups.com.

Nikhil Komalan

unread,
Sep 1, 2021, 2:58:04 AM9/1/21
to openthread-users
Okay Thanks.

I have successfully added the custom commands and it works as expected. But there is a problem now, whenever i enter help in Openthread CLI it throws some garbage data after listing out the commands.

Here is image for the issue:
- Data Start and Data Stop are my custom commands here
GarbageOnCLi.png

Jonathan Hui

unread,
Sep 1, 2021, 3:15:03 AM9/1/21
to Nikhil Komalan, openthread-users
Did you set the array length to the appropriate size (i.e. 2 in your case)?

--
Jonathan Hui



Nikhil Komalan

unread,
Sep 1, 2021, 3:28:34 AM9/1/21
to openthread-users
Okay. That was the issue with the size.

When i used size of function it outputted garbage in the end. When i directly pass value, it works as expected.
"
    otCliSetUserCommands(myuser_commands, sizeof(myuser_commands));
Message has been deleted

Jonathan Hui

unread,
Sep 1, 2021, 1:06:06 PM9/1/21
to Nikhil Komalan, openthread-users
There are many examples of parsing command line args in src/cli/cli.cpp.

--
Jonathan Hui



On Wed, Sep 1, 2021 at 1:52 AM Nikhil Komalan <nkoma...@gmail.com> wrote:
Hello Jonathan,

How to deal the values passed in the CLI. Is there any example or code snippet for that. The above link which you mentioned helped me to start, stop my application. But if i have to pass duration or any such value, how could i read the value from the CLI. For example openthread panid, channel commands.

Nikhil Komalan

unread,
Sep 6, 2021, 2:30:03 AM9/6/21
to openthread-users
Hello Jonathan,

I would like to display the Error Messages on open thread CLI. Is there anyway of changing the color of the text like for Error Message it should be Red, for INFO messages it can be green. In open thread CLI file i don't see any color options.
Reply all
Reply to author
Forward
0 new messages