Commit graph

39 commits

Author SHA1 Message Date
Anas Nashif e1d284f648 shell: rename get_mod_cmd
rename function and call out module in the name.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-19 12:01:08 -05:00
Anas Nashif d7777d3bd5 shell: support standalone commands
This will allow us to register commands directly without a need for a
module.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-19 12:01:08 -05:00
Anas Nashif 8d1931504a shell: rename module sections
Prepare for supporting stand-alone commands.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-19 12:01:08 -05:00
Anas Nashif 16424cf0bc shell: kernel: rename tasks -> threads
Rename tasks -> threads, task was the common name for threads before the
unified kernel was introduced.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-19 12:01:08 -05:00
Anas Nashif dd013691b2 shell: add a shell banner
Give details about running version and add a line about usage.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-19 12:01:08 -05:00
Carles Cufi 7d764b35f3 cmake: Use path-corrected version of ZEPHYR_BASE
Instead of accessing the environment variable ZEPHYR_BASE every time we
require accessing the source code root, use an intermediate variable
that has OS path separators correctly set to '/' to avoid issues on
Windows.

Note: This removes the ZEPHYR_SOURCE_DIR CMake variable. External
applications using that will need to change to use the new ZEPHYR_BASE
variable.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-01-11 14:59:03 -05:00
Anas Nashif 429c2a4d9d kconfig: fix help syntax and add spaces
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-13 17:43:28 -06:00
Johan Hedberg 45f258686b shell: Fix looking up help for the current module
The code was not properly handling "help <cmd>" for the currently
selected module.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-15 16:04:39 +02:00
Johan Hedberg 7318904ae1 shell: Use struct shell_module instead of integer to refer to modules
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>
2017-11-15 16:04:39 +02:00
Johan Hedberg 22b5ff9b29 shell: Redesign internal command handling
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>
2017-11-15 16:04:39 +02:00
Johan Hedberg 329a6628e4 shell: Remove unnecessary function
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>
2017-11-15 16:04:39 +02:00
Johan Hedberg f9e30ed582 shell: Fix command lookup for non-default modules
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>
2017-11-15 16:04:39 +02:00
Johan Hedberg fe20f55d03 shell: Remove redundant checking for argv[0]
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>
2017-11-15 16:04:39 +02:00
Johan Hedberg 74556b7abb shell: Fix unnecessary passing by reference of argc
The get_cb() function does not modify argc, so there's no point in
passing it by reference.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-15 16:04:39 +02:00
Johan Hedberg 39a733151d shell: Remove unnecessary first_string variable
This variable adds no value, and is in fact longer to spell out than
simply argv[0].

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-15 16:04:39 +02:00
Johan Hedberg 76fb522993 shell: Remove redundant checking for first parameter
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>
2017-11-15 16:04:39 +02:00
Johan Hedberg 04fbb80adb shell: Remove unnecessary initialization of err
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>
2017-11-15 16:04:39 +02:00
Johan Hedberg 7f6070fb6c shell: Add optional command description
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>
2017-11-15 07:51:02 +02:00
Johan Hedberg c87ecf58de shell: Include the command help when listing all commands
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>
2017-11-14 21:32:20 +02:00
Sebastian Bøe 0829ddfe9a kbuild: Removed KBuild
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Sebastian Bøe 12f8f76165 Introduce cmake-based rewrite of KBuild
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>
2017-11-08 20:00:22 -05:00
Luiz Augusto von Dentz 81cc89189b shell: Adjust arguments when executing a command of different module
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>
2017-06-09 18:54:27 -04:00
Luiz Augusto von Dentz 417dc03aad shell: Return proper errors if the command fails
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>
2017-06-09 18:54:27 -04:00
Luiz Augusto von Dentz 1a8cd31d64 shell: Add shell_exec
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>
2017-06-09 18:54:27 -04:00
Andrew Boie 567c6c7683 misc: use K_THREAD_STACK_DEFINE macros
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-06-09 18:53:28 -04:00
Siddharth Chandrasekaran faaf859a46 shell: Add 'exit' command to leave a module
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>
2017-05-30 20:45:55 -04:00
Luiz Augusto von Dentz 6213730154 Shell: Add SHELL_REGISTER_WITH_PROMPT
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>
2017-05-29 10:42:21 +03:00
Andrew Boie 77d1f1d232 shell: use k_thread_create()
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-05-11 20:24:22 -04:00
Kumar Gala 6da829690f subsys: convert to using newly introduced integer sized types
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>
2017-04-21 09:36:22 -05:00
Tomasz Bursztyka f7b0e35c5f shell: If enabled, let's register telnet console as an input
Change-Id: I476ca0f7914b02d2523a341560023c7e334d8b1b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-01-27 12:35:53 +02:00
Tomasz Bursztyka 587335c6cf shell: Make the command queue size configurable via Kconfig
Change-Id: I80551c76903118bfe831776c87135e89d32552da
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-01-27 12:35:53 +02:00
Tomasz Bursztyka 2f1af492ee console/shell: Switch to generic console input
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>
2017-01-27 12:35:53 +02:00
Tomasz Bursztyka 1a52e6e91a shell: Fix tiny style issues
- identation alignment
- 80 chars length limit

Change-Id: Ieae83e0daa2c7ee7aff32a053db5692094488df7
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-01-27 12:35:53 +02:00
Benjamin Walsh ed240f2796 kernel/arch: streamline thread user options
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>
2017-01-24 13:34:50 +00:00
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
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>
2017-01-19 03:50:58 +00:00
Anas Nashif f1d0c2b0ad shell: add stacks command
Change-Id: Ibefface37c38749043602bce29317a315d0b53fd
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-01-11 20:47:10 +00:00
Anas Nashif 36c5167b72 shell: add tasks command to kernel module
Change-Id: I67c497c04e3c92a7f55cc5d95d7d3cfea414b4d8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-01-11 20:47:09 +00:00
Anas Nashif 502f0c893c shell: rename command 'set_module' to 'select'
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>
2017-01-11 19:20:57 +00:00
Anas Nashif 7297f5db88 shell: move shell to its own subsystem
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>
2016-12-25 19:35:11 +00:00