`#ifdef` will always evaluate to true when used on string Kconfig options.
Therefore username and password is set to "" if unset in Kconfig which is
not an issue.
Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
Replace `select NET_MGMT` and `select NET_MGMT_EVENT` with
`select NET_CONNECTION_MANAGER` to get L4 events.
Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
Change topic from <device_id>_rx (and tx) to <device_id>/sh/rx.
This allows use of wildcards. E.g. subscribe to all devices "+/sh/tx".
Level "sh" is added to the topic to make it less generic and prevent
potential clashes with other topics.
The topic part after <device_id> is configurable via Kconfig.
Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
The interrupt-driven UART API is emulated via polling on native_sim,
which introduces additional overhead. Defaulting to poll mode improves
performance by avoiding this emulation cost.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
It might come in handy to filter the output of a device list
command, by adding a filter (auto-completion enabled as well).
Such as:
$ device list uart
devices:
- uart@2f8 (READY)
DT node labels: uart1
- uart@3f8 (READY)
DT node labels: uart0
Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
Co-authored-by: Dimitris Karnikis <dika@bang-olufsen.dk>
Co-authored-by: Hans Binderup <habi@bang-olufsen.dk>
It might come in handy to access non-initialized devices throuhg the
shell. I.e. devices which 'zephyr,deferred-init' DTS attribute was set.
Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
It is actually easy to have device name going beyond 20 characters.
There is a maximum defined internally, better using it.
Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
Allow changing delays via Kconfig values.
Use identical delay (`SHELL_MQTT_WORK_DELAY_MS`) for connect, subscribe and
process work instead of varying 1 or 2 second delay.
Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
This commit brings a shell command to retreive the following application
version information:
- APP_VERSION_STRING
- APP_VERSION_EXTENDED_STRING
- APP_BUILD_VERSION
Signed-off-by: Alex Fabre <alex.fabre@rtone.fr>
The sh->ctx->uninit_cb needs to be set before posting the
SHELL_SIGNAL_KILL to the event, like the k_poll based code did prior to
Signed-off-by: Jeremy Bettis <jbettis@google.com>
The mutex is being used as a simple binary semaphore. It is not
recursed so we don't need to track thread ownership nor lock count.
Exchange the mutex for a binary semaphore to save resources and
speed up shell.
Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
The shell subsystem currently uses k_poll for signalling. However,
k_poll is only used for simple event signals, results are not used.
Replacing the k_poll with k_event greatly simplifies the code, and
saves 4 struct k_poll_signal and 4 struct k_poll_event (one of which
was entirely unused) while costing a single struct k_event, for
every shell instance. It also allows us to not select POLL,
as we are using the simpler EVENTS instead.
A quick test build of the shell test suite on an nrf54l15 produces
the following build info:
using EVENTS:
FLASH: 71592 B 1428 KB 4.90%
RAM: 9872 B 188 KB 5.13%
IDT_LIST: 0 GB 32 KB 0.00%
using POLL
FLASH: 75524 B 1428 KB 5.16%
RAM: 11224 B 188 KB 5.83%
IDT_LIST: 0 GB 32 KB 0.00%
Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
Instead of using 32 bit enum values for event numbers, convert
the code to use 64 bit long bit fields. This means that the
user API is changed to use 64 bit event values instead of 32
bit event values.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The 50 ms TX mutex timeouts introduced in commit b0a0feb cause
dropped messages when used with the shell log backend. This
commit makes time timeout configurable using the
CONFIG_SHELL_TX_TIMEOUT_MS Kconfig option and makes the
default timeout longer when shell log backend is enabled.
Link: #90215
Signed-off-by: Tommi Kangas <tommi.kangas@nordicsemi.no>
In order to enable better and more consistent help messages for shell
commands, this commit introduces a new SHELL_HELP macro that allows to
document a command's description and usage in a more structured way.
This will allow to get rid of inconsistent (and duplicated!) variations
of "Syntax: ...", "Syntax:\n ...", "Usage: ...", in the commands, and
formatting of the description+usage will be taken care of by the shell
when it detects the help message is using the "structured" format.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Lines following newlines in shell help text were not properly indented.
For example, in "abc def\ndef ghi\njkl mno", the lines "def ghi" and
"jkl mno" would appear without the expected left margin.
The issue was that after processing a newline and setting proper cursor
position, the function would fall through to z_shell_raw_fprintf() which
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The `sh_mqtt_rx_rb_flush` function was intended to flush `rx_rb` when
get an error return from `mqtt_read_publish_payload_blocking`.
Instead of retrieving values from `rx_rb` one by one, calling
`ring_buf_reset` achieves the same result more efficiently.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Introduce a local pointer, `struct shell_mqtt *sh`, to minimize access
to the module-scoped `sh_mqtt` variable.
This allows `sh` to be stored in a CPU register, resulting in more
compact code and improved execution efficiency.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
For testing purposes only. Testing the fatal error handler or
a coredump backend. Or just out of curiosity.
Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
Add support for DICONNECT message specified in MQTT 5.0.
As with MQTT 5.0, the disconnect can now also be initiated by the
broker, it was needed to add decoder support for the message.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Set the default maximum argument count for the shell to 30
when the Wi-Fi shell is enabled, to ensure all Wi-Fi
commands work without failure.
Signed-off-by: Triveni Danda <triveni.danda@nordicsemi.no>
If the RTT shell backend is selected and the "down" buffer size
has been selected, the shell bypass functionality should instead
use the buffer size specified by the configuration.
Signed-off-by: Christopher Clingerman <christopher.clingerman@sensorfy.ai>
PR #84651 introduced new shell commands that don't compile if
CONFIG_THREAD_MONITOR=n
Add THREAD_MONITOR to new shell commands.
Signed-off-by: Jeremy Bettis <jbettis@google.com>
This commit extends the shell command functionality by
adding three new operations for thread management.
kernel thread suspend <thread_id>:
Suspends any thread based on its identifier.
kernel thread resume <thread_id>:
Resumes the thread that was previously suspended.
kernel thread kill <thread_id>:
Terminates any thread based on its identifier
These extended commands are useful for controlling
any threads through Zephyr Shell.
Signed-off-by: S Swetha <s.swetha@intel.com>
When reprinting the shell command buffer with long user inputs, the
reprinted buffer may cross a line boundary, and require a newline to be
printed. For these cases, print the command buffer character by
character, inserting newlines as appropriate.
Fixes#82155
Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Fixes an issue where the shell API could block indefinitely when called
from threads other than the shell's processing thread, especially when
the transport (e.g. USB CDC ACM) was unavailable or inactive.
Replaced `k_mutex_lock` calls with an indefinite timeout (`K_FOREVER`)
by using a fixed timeout (`K_MSEC(SHELL_TX_MTX_TIMEOUT_MS)`) in shell
API functions to prevent indefinite blocking.
Link: https://github.com/zephyrproject-rtos/zephyr/issues/84274
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
Introduced a new Kconfig option `SHELL_PRINTF_AUTOFLUSH` to allow
configuring the autoflush behavior of shell printing functions.
Updated `Z_SHELL_FPRINTF_DEFINE` to use the
`CONFIG_SHELL_PRINTF_AUTOFLUSH` setting instead of hardcoding
the autoflush behavior to `true`.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
Log_level command is a duplicate of 'log enable' command from
the logging command set (enabled by CONFIG_LOG_CMDS=y). Adding
warning about deprecation as 'log enable' is recommended since
it has more features (e.g. autocompletion).
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
fix coverity issue about deadcode, there is no code path which would
lead to the code that is being deleted with this commit
Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
In case websocket logger is disabled, the websocket shell backend should
still build, fix that.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case websocket logging is enabled, the websocket shell should not be
configured as a logger backend, otherwise logs are duplicated.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Wrong symbol was used for log level when registering logger instance for
websocket shell, causing misconfiguration and in result unexpected
crashes.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Mostly a revert of commit b1def7145f ("arch: deprecate `_current`").
This commit was part of PR #80716 whose initial purpose was about providing
an architecture specific optimization for _current. The actual deprecation
was sneaked in later on without proper discussion.
The Zephyr core always used _current before and that was fine. It is quite
prevalent as well and the alternative is proving rather verbose.
Furthermore, as a concept, the "current thread" is not something that is
necessarily architecture specific. Therefore the primary abstraction
should not carry the arch_ prefix.
Hence this revert.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Passing HTTP upgrade request context to the user callback allows the
user to decide whether to accept or reject the websocket connection
based on the HTTP headers in the request. The primary reason for this is
to enable authentication of the websocket connection (e.g. via cookies
or Authorization header).
Signed-off-by: Matt Rodgers <mrodgers@witekio.com>
This commit includes cleanups to `kernel_service`:
- `shell_tdata_dump()`:
Adjust formatting to align with `.clang-format`.
- `shell_stack_dump()`:
Update to pass `sh` directly instead of `user_data` since
it is already assigned.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Switch from using direct `strtoul` calls to `shell_strtoul`.
This change leverages the extensive error handling provided
by `shell_strtoul`.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
As `strtoul`, `strtoll`, and `strtol` guarantee to set `endptr`,
the initial `NULL` can be omitted.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
RTT backend can only be called from thread context and immediate
logging might lead to interrupt context use. Previously this limitation
was implied in different way and commit (c88a9ef27) got reverted.
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Added shell_device_get_binding() that wraps device_get_binding() plus
device_get_by_dt_nodelabel() so that a shell can easily get a device by
its full name or label.
Signed-off-by: Yishai Jaffe <yishai1999@gmail.com>
`_current` is now functionally equals to `arch_curr_thread()`, remove
its usage in-tree and deprecate it instead of removing it outright,
as it has been with us since forever.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>