Extend the echo()
function in main.c
to print the first argument to the command handler
int cmd_handler(int argc, char **argv);
Any parameters following the shell command in the RIOT shell are accessible
from the argv
variable. argc
contains the number of parameters used to call
this shell command plus one for the name of the command.
Your function must return 0
if it runs successfully and or anything else if
an error occurs.
Shell commands need to be added manually to the shell on initialization
#include "shell.h"
static const shell_command_t shell_commands[] = {
{ "command name", "command description", cmd_handler },
{ NULL, NULL, NULL }
};
/* ... */
shell_run(commands, line_buf, SHELL_DEFAULT_BUFSIZE)
/* ... */
Please note, that the list of shell commands must be terminated with an empty entry.