Commit Graph

26 Commits

Author SHA1 Message Date
Xiaoyu Liu
9a5ca8fac6 feat(console): Add an API function to de-register the specified console command 2024-06-03 10:48:22 +08:00
Xiaoyu Liu
18f6be771d feat(system/console): add help command verbose level option
Support users to demonstrate command info in different verbose levels.

Closes https://github.com/espressif/esp-idf/issues/9158
2024-05-27 10:47:40 +08:00
Peter Marcisovsky
0bfaf775c1 refactor(console): Enable astyle formatting 2024-04-29 16:12:51 +02:00
Alon Bar-Lev
93706028de
change(console): drop the use of open_memstream()
the argtable3 provides string based output return, there is no need to go via
stdio structures.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Signed-off-by: Ivan Grokhotkov <ivan@espressif.com>
Closes https://github.com/espressif/esp-idf/pull/12507
2024-03-28 14:09:01 +01:00
Jakob Hasse
0b246b8c0b refactor(console): made help command sorting depend on Kconfig option 2024-03-21 16:33:44 +08:00
Jakob Hasse
4d629be602 refactor(linux): Unified libbsd handling
* Users can now use libbsd string.h and sys/cdefs.h functionality
  (e.g., strlcpy, containerof) on Linux by just including
  string.h or sys/cdefs.h. In other words, the includes are the same
  on the Linux target as well as on chips targets (ESP32, etc.).
* libbsd linking is done by the linux component (belongs to common
  components) now instead of handling it separately in each component
2024-03-08 12:26:54 +08:00
Jakob Hasse
a30546cd24 feat(console): Refactored code to support Linux target 2024-01-29 17:13:22 +08:00
Jakob Hasse
6031b35803 fix(console): Made setting command context less error-prone and clearer 2024-01-11 10:53:43 +08:00
Alon Bar-Lev
bccb2873bd feat(console): add command user context support
Current implementation implicitly forces the developer to use global variables
to enter its context during the command invocation, this change enables each
module to register a context for command to find without the need to manage
global variables.

No API breakage.

Fields added:
   esp_console_cmd_t::func_w_context    - (*)(int argc, char **argv, void *context)

Functions added:
   esp_err_t esp_console_cmd_set_context(const char *cmd, void *context)

Usage:

   esp_console_cmd_register(&cmd));
   esp_console_cmd_set_context(cmd.command, (void *)"context"));

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2023-12-13 10:27:04 +08:00
Alon Bar-Lev
07a9137fd7 change(console): print sorted help
console commands may be registered in random order in application, for example
each module registers its own commands.

the output of help is displayed to human, best to have consistent sorted
output so that the implementation ordering will not affect the output and
allow the user to see a list in some logic order.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
2023-11-09 10:18:42 +02:00
Jakob Hasse
7b258bef0e refactor(esp_console): improved error handling, added tests and docs
* Updated documentation of
  esp_console_register_help_command
* Improved help command error handling
* Added test for the help command
2023-08-15 14:11:30 +08:00
Josef Norgan
f317cc55f2 feat(esp_console): Added Help command parameter for displaying only specific command 2023-08-15 10:09:37 +08:00
Marius Vikhammer
f80430911f fix(console): fixed esp_console_init not working if heap_alloc_caps was 0 2023-08-10 10:35:32 +08:00
Marius Vikhammer
1ec1a69ed0 feature(console): updated console alloc config to use static config struct
No need to store the config in a separate variable, can re-use the config struct
2023-08-03 10:19:15 +08:00
Chip Weinberger
9178748ff3 [Console] add heap caps settings 2023-08-01 23:38:47 -07:00
Jan Brudný
28a94328d4 console: update copyright notice 2021-05-17 03:41:32 +02:00
morris
753a929525 global: fix sign-compare warnings 2021-01-12 14:05:08 +08:00
suda-morris
75cadc2e41 console: simplify examples
1. simplify console examples
2. add "quit" command
3. support console command overwrite
4. add API reference
2020-02-07 20:15:06 +08:00
Anton Maklakov
afbaf74007 tools: Mass fixing of empty prototypes (for -Wstrict-prototypes) 2019-08-01 16:28:56 +07:00
morris
c159984264 separate rom from esp32 component to esp_rom
1. separate rom include files and linkscript to esp_rom
2. modefiy "include rom/xxx.h" to "include esp32/rom/xxx.h"
3. Forward compatible
4. update mqtt
2019-03-21 18:51:45 +08:00
Renz Bagaporo
8ce14d0406 console: Suppress unused warning asprintf result 2018-07-24 06:08:48 +00:00
Anuj Deshpande
87adbd3229 console: Fix formatting 2018-04-30 14:22:45 +05:30
Anuj Deshpande
b3894dba97 console: Free alloc'd memory after error conditions
Closes https://github.com/espressif/esp-idf/issues/1901
2018-04-30 14:21:03 +05:30
Ivan Grokhotkov
4d42b5ea24 console: handle empty input to esp_console_run correctly
Fixes https://github.com/espressif/esp-idf/issues/1067

Ref. TW15752
2017-10-13 07:14:53 +08:00
Ivan Grokhotkov
0ed64da963 console: initialize buf_size before calling open_memstream
POSIX open_memstream documentation [1] does not mention that it may use
the  value supplied in buf_size before the call.
newlib implementation of open_memstream does use it as a hint of the
buffer size [2]. To avoid using potential garbage in this variable,
newlib caps the size to 64kB (!).

If the allocation of this initial buffer fails, NULL file pointer is
returned. Previous code did not check returned file pointer and crashed
when it was used.

Initialize size to zero (in which case newlib allocates a 64 byte
buffer), and check the returned file pointer.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/open_memstream.html
[2] https://github.com/espressif/newlib-esp32/blob/23c0f21/newlib/libc/stdio/open_memstream.c#L26-L29
    https://github.com/espressif/newlib-esp32/blob/23c0f21/newlib/libc/stdio/open_memstream.c#L324-L336
2017-08-23 01:10:30 +08:00
Ivan Grokhotkov
5de7c91a54 add console component and example 2017-08-21 15:58:27 +08:00