@@ -19,41 +19,44 @@ Use one of the following formats:
19
19
20
20
Specific module's commands
21
21
==========================
22
- `MODULE_NAME COMMAND `
23
- One of the available modules is “KERNEL”, for the Kernel module.
24
- More information can be found in :c:macro: `SHELL_REGISTER `.
22
+ `MODULE_NAME COMMAND `
23
+ One of the available modules is “KERNEL”, for the Kernel module. More
24
+ information can be found in :c:macro: `SHELL_REGISTER `.
25
25
26
26
Help commands
27
27
=============
28
- `help `
29
- Prints the available modules.
30
- `help MODULE_NAME `
31
- Prints the names of the available commands for the module.
32
- `help MODULE_NAME COMMAND `
33
- Prints help for the module's command (the help should show function
34
- goal and required parameters).
28
+ `help `
29
+ Prints the available modules.
30
+
31
+ `help MODULE_NAME `
32
+ Prints the names of the available commands for the module.
33
+
34
+ `help MODULE_NAME COMMAND `
35
+ Prints help for the module's command (the help should show function
36
+ goal and required parameters).
35
37
36
38
Select module commands
37
39
======================
38
- `set_module MODULE_NAME `
39
- Use this command when using the shell only for one module.
40
- After entering this command, you will not need to enter module
41
- name in further commands.
42
- If the selected module has set a default shell prompt during its
43
- initialization, the prompt will be changed to that one.
44
- Otherwise, the prompt will be changed to the selected module’s name to
45
- reflect the current module in use.
46
- `set_module `
47
- Clears selected module. Restores prompt as well.
40
+ `set_module MODULE_NAME `
41
+ Use this command when using the shell only for one module. After entering this
42
+ command, you will not need to enter module name in further commands. If
43
+ the selected module has set a default shell prompt during its initialization,
44
+ the prompt will be changed to that one. Otherwise, the prompt will be
45
+ changed to the selected module’s name to reflect the current module in use.
46
+
47
+ `set_module `
48
+ Clears selected module. Restores prompt as well.
48
49
49
50
Shell configuration
50
51
*******************
51
52
There are two levels of configuration: Infrastructure level and Module level.
52
53
53
54
Infrastructure level
54
55
====================
56
+
55
57
The default value for ENABLE_SHELL flag should be considered per product.
56
58
This flag enables shell services.
59
+
57
60
If it is enabled, kernel shell commands are also available for use.
58
61
See the :option: `CONFIG_ENABLE_SHELL ` Kconfig options for more information.
59
62
@@ -62,6 +65,7 @@ Module level
62
65
Each module using shell service should add a unique flag in its Kconfig file.
63
66
64
67
Example:
68
+
65
69
CONFIG_SAMPLE_MODULE_USE_SHELL=y
66
70
67
71
In the module’s code, the shell usage depends on this config parameter.
@@ -73,51 +77,51 @@ The default value for ENABLE_SHELL flag should be considered per product.
73
77
74
78
Configuration steps to add shell functionality to a module
75
79
==========================================================
80
+
76
81
#. Check that ENABLE_SHELL is set to yes.
77
82
#. Add the module unique flag to its Kconfig file.
78
83
79
-
80
84
Writing a shell module
81
85
**********************
86
+
82
87
In order to support shell in your module, the application must do the following:
83
88
84
- #. Module configuration flag:
85
- Declare a new flag in your module Kconfig file.
86
- It should depend on `ENABLE_SHELL ` flag.
89
+ #. Module configuration flag: Declare a new flag in your module Kconfig file.
90
+ It should depend on `ENABLE_SHELL ` flag.
91
+
92
+ #. Module registration to shell: Add your shell identifier and register its
93
+ callback functions in the shell database using :c:macro: `SHELL_REGISTER `.
94
+
95
+ Optionally, you can use one of the following API functions to override default
96
+ behvior and settings:
87
97
88
- #. Module registration to shell:
89
- Add your shell identifier and register its callback functions in the
90
- shell database using :c:macro: `SHELL_REGISTER `.
98
+ * :c:func: `shell_register_default_module `
91
99
92
- #. Optional:
93
- :c:func: `shell_register_default_module `
100
+ * :c:func: `shell_register_prompt_handler `
94
101
95
- :c:func: `shell_register_prompt_handler `
102
+ In case of a sample applications as well as test environment, user can choose to
103
+ set a default module in code level. In this case, the function
104
+ shell_register_default_module should be called after calling SHELL_REGISTER in
105
+ application level. If the function shell_register_prompt_handler was called as
106
+ well, the prompt will be changed to that one. Otherwise, the prompt will be
107
+ changed to the selected module’s name, in order to reflect the current module in
108
+ use.
96
109
97
- Usage:
98
- In case of a sample applications as well as test environment,
99
- user can choose to set a default module in code level.
100
- In this case, the function shell_register_default_module should
101
- be called after calling SHELL_REGISTER in application level.
102
- If the function shell_register_prompt_handler was called
103
- as well, the prompt will be changed to that one.
104
- Otherwise, the prompt will be changed to the selected module’s
105
- name, in order to reflect the current module in use.
106
110
107
- Note :
108
- Even if a default module was set in code level, it can be
109
- overwritten by “set_module” shell command.
111
+ .. note : :
112
+ Even if a default module was set in code level, it can be overwritten by
113
+ “set_module” shell command.
110
114
111
- When to use shell_register_default_module:
115
+ You can use :c:func: ` shell_register_default_module ` in the following cases :
112
116
113
- * Use this command in case of using the shell only for one module.
114
- After entering this command, no need to enter module name in further
115
- commands.
117
+ * Use this command in case of using the shell only for one module.
118
+ After entering this command, no need to enter module name in further
119
+ commands.
116
120
117
- * Use this function for shell backward compatibility.
121
+ * Use this function for shell backward compatibility.
118
122
119
- More details on those optional functions can be found
120
- in :ref: `shell_api_functions `.
123
+ More details on those optional functions can be found in
124
+ :ref: `shell_api_functions `.
121
125
122
126
123
127
.. _shell_api_functions :
0 commit comments