It's much more intuitive to read "if (module)" instead of
"if (module != -1)" when checking for a valid module. Update the code
to use struct shell_module pointers instead of integers for tracking
modules.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Make the internal commands (exit, select & help) as any other
commands, so that e.g. "help help" works as expected. Also redesign
the way commands are looked up to avoid duplicate lookups.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The print_cmd_unknown() is just a two-liner and only called from a
single place, so just do the printk calls inline.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The code was completely broken wrt command lookups when the command is
given in the format "<module> <cmd> <args...>". It would only work if
the default module is not set, which is almost never the case (as most
apps set it explicitly).
Refactor the command handling by moving more logic up to shell_exec(),
so that get_cb() does a lookup for a single module
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The way get_command_and_module() is used it's impossible for it to be
given an argv where argv[0] is NULL.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The way the command line parsing works, argv[0] is always guaranteed
to be non-NULL as well as a non-empty string, so doing checks for this
in get_cb() is redundant.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
All code paths in shell_exec() are guaranteed to set err before
returning it, so doing this (rather curious) initialization is
completely unnecessary.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The command name and a shortened form of valid parameters is not
necessarily enough to understand its usage. Add the option of
providing a more lengthy description of the command usage.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Most commands provide a short string to describe the parameters it
takes. Provide this help text as part of the list of supported
commands for each module.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.
Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.
This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.
For users that just want to continue their work with minimal
disruption the following should suffice:
Install CMake 3.8.2+
Port any out-of-tree Makefiles to CMake.
Learn the absolute minimum about the new command line interface:
$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..
$ cd build
$ make
PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
The command callback might not recognize commands if the input comes
with the module name as first parameter as both argc and argv will be
off by one.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If the command cannot be execute code should return a proper since this
may not be a user input.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds shell_exec which can be used to execute commands directly
without the use of a console which is useful for both testing as well
as interfacing with applications/upper layer which would like to have
access to shell commands directly.
In addition to that this may be more trivial to interface with instead
of using fifos like uart_register_input and telnet_register_input do.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
In console shell, add explicit, 'exit' command to leave the current
module. Currently this is being achieved by overloading select command
(without an argument).
Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
This enables modules to define its own prompt handler instead of always
using the default_module_prompt.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.
Jira: ZEP-2051
Change-Id: Icbf9e542b23208890a3a32358447d44cdc274ef1
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Let's use the generic console input type now. This will be useful for
other console input drivers such as telnet.
Change-Id: I787a1e9d86481d5f8c4803453726d9042a89dea4
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
The K_<thread option> flags/options avaialble to users were hidden in
the kernel private header files: move them to include/kernel.h to
publicize them.
Also, to avoid any future confusion, rename the k_thread.execution_flags
field to user_options.
Change-Id: I65a6fd5e9e78d4ccf783f3304b607a1e6956aeac
Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.
Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.
Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file. Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.
Jira: ZEP-1457
Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
select is more intuitive and easy to remember, and it is shorter too :)
Change-Id: Icc79e5cb88163344c1e2fcf65e313c33c4afa2cc
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This moves the shell component into its own subsys and groups all
related files and options into a single place.
Additionally, one Kconfig option will now be required to enable the
shell:
CONFIG_CONSOLE_SHELL=y
The header files was also moved to include/shell/shell.h and can be now
referenced with
#include <shell/shell.h>
instead of
#include <misc/shell.h>
Updated documentation as well.
Change-Id: Iffbba4acfa05408055e9fd28dffa213451351f94
Signed-off-by: Anas Nashif <anas.nashif@intel.com>