MISRA Rule 5.7 requires uniqueness of tag identifiers. Shell is
frequently problematic because many code uses `const struct shell
*shell`. This causes CI noise every time one of these shell files is
edited, so let's update all of them with `const struct shell *sh`
instead.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
It was possible to deadlock the shell when command
suspended shell's thread and next another thread wanted
to print something on the shell.
To avoid that shell releases mutex before entering command
handler. Due to this change some adapations to shell
internal print functions have been applied.
This change addresses following usecase:
1. A command handler needs to call a (system) function which
communicate results via a callback, and this callback is expected
to print these results. The callback is called by the system from
another thread.
2. To achieve that, the handler needs to pass `struct shell *`
to callbacks, but also some other data specific to callback.
Thus, handles allocates some structure will those fields on
the stack.
3. The handler schedules this callback to be called.
4. As a reference to stack structure is passed to the callback,
the handler can't return immediately (or stack data will go out
of scope and will be overwritten).
5. So, the handler blocks waiting for callback to finish.
Previously, this scenario led to deadlock when the callback
trying or print to shell. With these changes, it just works,
as long as main handler and callback serialize there access
to the shell structure (i.e. when callback prints, the main
handler is blocked waiting for its completion).
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Added display text management to shell_fprintf function.
Now it can be used from diffrent threads with not risk that
displayed lines will overlay.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Everywhere the return of this function was being assigned to u16_t to
save space on stack. Instead of casting in all these places (and may
end up with overflow), just changing this function's return.
Note that the function itself is not checking for overflow yet since
I'm not sure this can happen and/or is a problem. Though now we have
only one single point to fix this problem.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
shell parses output string and it adds \r for each found \n.
It is no longer needed to keep \r for each shell message.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
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>
Extended shell to support wildcard characters: * and ? and expand
commands accordingly.
Increased default stack size.
Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>