If bypass mode is left outside of the registered bypass handler, the
command buffer was not cleared, basically containig leftovers from the
processing of the previous command. This resulted in undefined behaviour
on consecutive shell operations.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In some applications, there is a need to don't start the shell by
default, but run it later on some special condition.
When SHELL_AUTOSTART is set to n, the shell is not started after
boot but can be enabled later from the application code.
Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
188d2dfcca introduced a change where log message queue again
become configurable through Kconfig instead of being fixed in
the code. However, it updated only the configuration of an UART
backend. This commit updates other backends as well. Including
dummy backend which has fixed in the code value.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This allows the caller to dump a region of memory rather than
dumping one byte (word, etc) at a time. Additionally, it
respects alignment requirements so it works for e.g. 32-bit
register accesses.
Signed-off-by: Chris Friedt <cfriedt@meta.com>
This seems to have caused build failures in spite
of CI passing in PR 52653.
This reverts commit 0a02a4a2af.
Signed-off-by: Chris Friedt <cfriedt@meta.com>
If LOG_PRINTK is used then the buffer size needs to be larger to
account for the additional header/footer output from the shell.
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
Use LOG_MESSAGE_QUEUE_SIZE config instead of hardcoded value.
LOG_MESSAGE_QUEUE_SIZE default value has been changed to 512, so
it is now matching to the hardcoded value.
Signed-off-by: Wojciech Slenska <wsl@trackunit.com>
Change for loops of the form:
for (i = 0; i < CONFIG_MP_NUM_CPUS; i++)
...
to
unsigned int num_cpus = arch_num_cpus();
for (i = 0; i < num_cpus; i++)
...
We do the call outside of the for loop so that it only happens once,
rather than on every iteration.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
The device_service shell was missing the capability to list devices
registered in the EARLY init level.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Changes in device_service have triggered MISRA 5.7 violation CI error
(Tag name should be unique). Renamed shell to sh, same as some other
modules.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The _SYS_INIT_LEVEL* definitions were used to indicate the index entry
into the levels array defined in init.c (z_sys_init_run_level). init.c
uses this information internally, so there is no point in exposing this
in a public header. It has been replaced with an enum inside init.c. The
device shell was re-using the same defines to index its own array. This
is a fragile design, the shell needs to be responsible of its own data
indexing. A similar situation happened with some unit tests.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
`wait()` returns the retval of `zsock_poll()` which can be
negative but is currently unhandled.
This patch make sure that the error will be handled.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Minor MISRA-related fixes so that the conditionals are boolean
and precedence of statements are explicit.
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
Tests with shell commands will fail if they are started
before the shell backend is initialized or started.
Adding API function: shell_ready indicating shell readiness.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
As of today <zephyr/zephyr.h> is 100% equivalent to <zephyr/kernel.h>.
This patch proposes to then include <zephyr/kernel.h> instead of
<zephyr/zephyr.h> since it is more clear that you are including the
Kernel APIs and (probably) nothing else. <zephyr/zephyr.h> sounds like a
catch-all header that may be confusing. Most applications need to
include a bunch of other things to compile, e.g. driver headers or
subsystem headers like BT, logging, etc.
The idea of a catch-all header in Zephyr is probably not feasible
anyway. Reason is that Zephyr is not a library, like it could be for
example `libpython`. Zephyr provides many utilities nowadays: a kernel,
drivers, subsystems, etc and things will likely grow. A catch-all header
would be massive, difficult to keep up-to-date. It is also likely that
an application will only build a small subset. Note that subsystem-level
headers may use a catch-all approach to make things easier, though.
NOTE: This patch is **NOT** removing the header, just removing its usage
in-tree. I'd advocate for its deprecation (add a #warning on it), but I
understand many people will have concerns.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Add option to control formatting of the logging timestamp. By default
formatting is enabled which maintains backward compatibility.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
When shell was used as a log backend it did not enabled log_output
module used for string formatting. Adding missing dependency.
Original commit (b0072e1cea) was
reverted, reappling.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Increase deafult value of SHELL_ARGC_MAX configuration.
This allows users to utilize deeper nested shell menus without
risking maxing out the number of allowed arguments.
Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
When shell was used as a log backend it did not enabled log_output
module used for string formatting. Adding missing dependency.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Previous code provided incorrect argc value to handlers when a command
used SHELL_OPT_ARG_RAW option.
Fixes#48380
Signed-off-by: Eric Johnson <eric.johnson2@walgreens.com>
Many device pointers are initialized at compile and never changed. This
means that the device pointer can be constified (immutable).
Automated using:
```
perl -i -pe 's/const struct device \*(?!const)(.*)= DEVICE/const struct
device *const $1= DEVICE/g' **/*.c
```
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
It is frequent to find variable definitions like this:
```c
static const struct device *dev = DEVICE_DT_GET(...)
```
That is, module level variables that are statically initialized with a
device reference. Such value is, in most cases, never changed meaning
the variable can also be declared as const (immutable). This patch
constifies all such cases.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Use `kernel log-level modulename severity`
Also enable it for the Bluetooth Shell.
Then one can compile-in a lot of BT modules like so:
CONFIG_BT_DEBUG_HCI_CORE=y
CONFIG_BT_DEBUG_L2CAP=y
CONFIG_BT_DEBUG_ATT=y
CONFIG_BT_DEBUG_GATT=y
And at runtime select only, e.g. GATT
kernel log-level bt_hci_core 0
kernel log-level bt_l2cap 0
kernel log-level bt_att 0
And then re-enable L2CAP if needed later
kernel log-level bt_l2cap 4
And so on..
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
When LOG_MODE_IMMEDIATE is used, logs processed by the shell
log backend may be intertwined with messages printed by
shell commands running on the shell thread.
It is because the shell uses a mutex while the shell log
backend uses the IRQ lock for synchronization. Switch the
latter to use the mutex as well whenever it's possible.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
Renaming objects which had 2 in the name to indicate that
it is v2 specific. Once logging v1 has been removed such
suffixes are redundant.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Logging v1 has been removed and log_strdup wrapper function is no
longer needed. Removing the function and its use in the tree.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit corrects all `extern K_KERNEL_STACK_ARRAY_DEFINE` macro
usages to use the `K_KERNEL_STACK_ARRAY_DECLARE` macro instead.
Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
Remove v1 implementation from log_core and all references in the tree.
Remove modules used by v1: log_list and log_msg.
Remove Kconfig v1 specific options.
Remove Kconfig flags used for distinction between v1 and v2.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
If CONFIG_SHELL_STATS is disabled, shell->stats is NULL and
must not be dereferenced. Guard against it.
Fixes#44089
Signed-off-by: Alexej Rempel <Alexej.Rempel@de.eckerle-gruppe.com>
If the echo flag is disabled the cmd_buff isn't printed and the
characters in it must not be counted in this function.
Signed-off-by: Gerhard Jörges <joerges@metratec.com>
In order to bring consistency in-tree, migrate all subsystems code to
the new prefix <zephyr/...>. Note that the conversion has been scripted,
refer to zephyrproject-rtos#45388 for more details.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Fixed the issue when sometimes "update" is not called for the
last RXRDY signal. First, need to reset the signal and only
after that need to call the "update" function.
Signed-off-by: Yuriy Vynnychek <yura.vynnychek@telink-semi.com>