Commit graph

92 commits

Author SHA1 Message Date
Jakub Rzeszutko 9e958b405c doc: shell: update according to new help usage
Updated documentation according to recent changes:
1. Removed options from the shell.
2. Simplified help usage.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Jakub Rzeszutko 3064ca4f2f shell: creating new module for help functionality
1. Created new shell module: shell_help.
2. Simplified command handlers with new shell print macros.
3. Removed help functions from command handlers.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Jakub Rzeszutko e0be6a10b3 shell: printing command's help by shell engine
Removed printing command help from help handler. It is now
realized by the shell engine. This change saves a lot of flash
but still allows to print help in command handler with function
shell_help_print.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Jakub Rzeszutko 5451ff2848 shell: remove "options" concept
Removing help "options" from shell API.

Currently SHELL_OPT macro is not used by users. What is more
commit: a89690d10f ignores possible options created in
command handler by the user. As a result they are not printed
in help message.

Second, currntly implemented "options" in command handlers options are
implemented without SHELL_OPT macro.

And last but not least this change will allow to implement
help handler in a way that user will not need to think about calling
functions printing help in a command handler.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-12-05 15:15:44 +01:00
Krzysztof Chruscinski f78067e1f9 shell: Refactor RTT backend
Improved reception in the backend and replaced thread
with periodic timer as thread was used only to
periodically poll RTT data availability and using timer
is more RAM-wise efficient.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-12-04 16:24:44 -05:00
Jakub Rzeszutko 9643ed6d27 shell: fix double new line print for RTT backend
In case terminal sends `\r\n` on the Enter button
shell will go to the new line twice and it will print
prompt twice. This patch fixes it.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-11-29 11:54:56 +01:00
Jakub Rzeszutko 80a8cfc6b6 shell: fixing printing macros
Update macros: shell_warn and shell_info to use correct
colour formatting.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-11-26 19:13:55 +01:00
Krzysztof Chruscinski 96a610b736 shell: Fix log messages queueing for multiple instances
Shell log backend was using k_fifo to enqueue log messages.
It was using field in log message that was used for same
purpose in log_core before passing message to backends.
However, this method supported only single shell as
other shell was corruption the fifo because field was
reused.

Modified shell log backend to use k_msgq for pending
messages.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-11-22 13:14:49 -05:00
Krzysztof Chruscinski af973ca1e9 shell: enable UART backend without interrupts
Currently shell UART backend is interrupt driven if UART driver
is interrupt driven. That can be limitation if one instance
wants to use interrupts but shell UART should not.

Added option to shell uart to be able to control use of
interrupts. By default interrupts are enabled if driver
supports it.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-11-21 22:41:21 -05:00
Jakub Rzeszutko 7d31796416 shell: fix shell thread name
Each shell thread will have unique name.
Previously thread name "shell" has been created for each shell
backend.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-11-19 11:40:05 -05:00
Luiz Augusto von Dentz 6c95b555ac shell: Add macros to print messages
This adds macros for printing info, normal, warning and error messages
including line termination.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-11-09 11:19:49 +01:00
Luiz Augusto von Dentz a89690d10f shell: Add APIs to set number of arguments
This allows the shell core to perform precheck before calling the
handler which then can assume the number of arguments is correct.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-11-09 11:19:49 +01:00
Krzysztof Chruscinski 4962618e5f shell: shell_uart: add ring_buffers and interrupt support
Improved RX path to use ring buffer for incoming data instead of single
byte buffer. Improved TX path to use ring buffer. Added support for
asynchronous UART API (interrupts).

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-11-06 17:11:26 -05:00
Christoph Schramm f17a9c93b4 shell: Add a Segger RTT backend
Fixes: #8394

Signed-off-by: Christoph Schramm <schramm@makaio.com>
2018-11-02 12:19:58 -04:00
Jakub Rzeszutko c3bc7180b0 subsys: shell: add dummy backend to simplify commands testing
Added dummy backend which can be enabled with Kconfig. By default it is
disabled because it needs the same amount of memory as other phisical
backends. It shall be use only for commands testing purposes.

Improved shell_execute_cmd function, now it clears command context
before new command will be executed.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-10-28 11:45:41 -04:00
Jakub Rzeszutko 4c420ff3bf shell: fix history feature
When user was typing a new command and next pressed an up arrow
shell has displayed previously executed command. Next it was not
possible to display back currently edited command using a down arrow.

Fixes #10766.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-10-24 14:31:25 +01:00
Jakub Rzeszutko a88d5d7e4f shell: commands help unification
1. Changed return value of function: shell_cmd_precheck from bool to
int. Now it returns:
  0       when argument count is correct and help print is not requested
  1       when help was requested and printed
  -EINVAL on wrong arguments count
This change simply shell_cmd_precheck usege in command handlers.

2. Unified all commands in shell_cmd.c file.

3. Fixed a bug where help was not printed on wrong argument count.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-10-19 13:35:56 +02:00
Krzysztof Chruscinski 5f6070e2f7 logging: Add autostart option to LOG_BACKEND_DEFINE
Extended macro to accept flag indicating if given backend must be
initialized and enabled when log subsystem starts. Typically, simple
backends will have autostart flag set. More complex may require
explicit enabling (e.g. shell over BLE can only be enabled when
BLE connection is established).

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-10-11 13:29:50 +03:00
Jakub Rzeszutko b0571746e2 shell: parsing output LF character
Some terminals literally interprets shell output data. Hence to print
a message in new line shell needs to send `\r\n` each time. To minimize
flash usage user can now send `\n` as a line delimiter and shell will
automatically add missing CR character.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-10-10 10:45:28 +02:00
Jakub Rzeszutko c471614cb6 subsys: shell: fix accept either CR or LF as as line delimiter
1. Shell will accept CR or LF as line delimiter.
2. Macro SHELL_DEFINE simplified - it no longer requires
   new line character.
3. Fixes: #10207.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-10-02 11:55:47 -07:00
Jakub Rzeszutko 61ca8c17c8 subsys: shell: add handlers diagnostic function
Added function: shell_execute_cmd that can be called
for command diagnostic purposes.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-10-02 14:44:25 +02:00
Jakub Rzeszutko 0eea1ef212 subsys: shell: add int ret_val to command handlers
1. Command handler can return command exectution status as int.
2. Existing command handlers rework.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-10-02 14:44:25 +02:00
Jakub Rzeszutko bef64c3b77 doc: subsystems: shell: Add documentation.
1. Remove old shell documentation.
2. Create documentation for new shell module.
3. Fix shell.h comments to be able to generate
   API documentation.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-09-29 14:42:05 -04:00
David B. Kinder 1692790d32 doc: fix misspellings in API headers
Fix misspellings in header file doxygen comments used to generate API
documentation, missed during regular reviews.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-09-27 05:57:14 +05:30
Jakub Rzeszutko 73c2178027 shell : assert standardization
1. All macros assert have been replaced with __ASSERT_NO_MSG.
2. Macro _Static_assert has been replaced with BUILD_ASSERT.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-09-25 10:31:13 +02:00
Jakub Rzeszutko e59b8cbef9 subsys : shell : Added API changing prompt
1. Added API to change shell prompt in runtime.
2. Added prompt buffer length configuration in Kconfig.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2018-09-24 13:17:24 +02:00
Krzysztof Chruscinski c71a5595dc shell: Extend shell as a log backend
Initial logger backend support added to shell.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-09-19 09:30:29 -04:00
Krzysztof Chruscinski 82ca811661 shell: Add shell history feature
Extending shell with terminal-like  history feature.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-09-19 09:30:29 -04:00
Krzysztof Chruscinski 6aed72e487 shell: Shell subsystem reimplementation
New shell support features like:
- multi-instance
- command tree
- static and dynamic commands
- multiline
- help print function
- smart tab (autocompletion)
- meta-keys
- history, wildcards etc.
- generic transport (initially, uart present)

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Signed-off-by: Piotr Zięcik <piotr.ziecik@nordicsemi.no>
2018-09-19 09:30:29 -04:00
Krzysztof Chruscinski 527256501f shell: Rename shell to legacy_shell
New shell implementation is on the way. For now old one and all
references are kept to be gradually replaced by new shell.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2018-09-19 09:30:29 -04:00
Szymon Janc 9d3237c89e shell: Add support for custom line2argv callback
This allows to define shells which are using different syntax for
commands parsing eg. foocmd=param1,param2.

This is usefull for providing compatibility with existing external
tools while allowing to use Zephyr's shell subsystem.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2018-09-18 12:54:44 +02:00
Flavio Ceolin 67ca176754 headers: Fix headers across the project
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04:00
Christopher Collins 76bf5646d5 subsys: mgmt: Shell transport for SMP (mcumgr).
Enable the shell to transport mcumgr SMP requests and responses.

Signed-off-by: Christopher Collins <ccollins@apache.org>
2018-02-20 22:07:52 +01:00
David B. Kinder 79e916542a doc: fix misspellings in doxygen API comments
Fix misspellings in API documentation derived from header files.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-01-30 20:04:21 -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
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
Luiz Augusto von Dentz 4b5aef7ee4 shell: Add define to _SHELL_H_
This prevents the header to be included multiple times.

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
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
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 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