shell: Refactor shell_history to use less RW memory

Shell history module reworked to use ring buffer for storing
commands. Dedicated buffer is used to story all command lineary.
History capacity is in bytes not in number of entries, e.g.
many short commands can be stored or few long (depending on
CONFIG_SHELL_HISTORY_BUFFER).

Removed implicit command null termination from shell_history and
added it to shell after fetching command line from the history.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2019-02-05 14:27:31 +01:00 committed by Anas Nashif
commit c2cb60f613
5 changed files with 198 additions and 61 deletions

View file

@ -99,6 +99,7 @@ config SHELL_HELP_ON_WRONG_ARGUMENT_COUNT
config SHELL_HISTORY
bool "Enable history in shell"
default y
select RING_BUFFER
help
Enable commands history. History can be accessed using up and down
arrows.
@ -107,7 +108,7 @@ if SHELL_HISTORY
config SHELL_HISTORY_BUFFER
int "History buffer in bytes"
default 1024
default 512
help
Number of bytes dedicated for storing executed commands.