Table of Contents |
---|
Before going into an example of µC/Shell usage, a few design concepts have to be explained. Since µC/Shell is not associated with any particular product, modules in need of a shell facility (such as µC/TELNETs) interact with it by means of an application callback function. This way, those modules are able to use or not to use the shell in a totally transparent manner.
...
Maximum length for module command name, including the termination NUL
character.
...
µC/
...
Shell Internal Details
At initialization time, that is when the Shell_Init()
function is called, two module command pools are being created: the free and the used. Right after initialization, no module command are being used, so all of the SHELL_CFG_CMD_TBL_SIZE
module command are located into the free pool, and the used pool is empty, like displayed below (SHELL_CFG_CMD_TBL_SIZE
set to 3 in this example).
Figure 3-1 - Pools after initialization
Adding module command tables to the shell with Shell_CmdTblAdd()
results in a free module command being taken from that pool, initialized, and taken into the used pool. Below is a representation of the pools after two module command tables have been inserted.Figure 3-2 - Pools after modules insertion
When the Shell_Exec()
function is being called in order to parse a line and execute a command, the lists of module commands have to be searched to find a match. Since the module command tables are inserted in a way analog to a stack, the search begins with the last addition. For instance, if the ‘OS
’ table has been inserted just after the ‘Net
’ one, command search will always look at the ‘OS’ command table, then proceed with the ‘Net
’ command table if a match has not been found.
Two searches are necessary to locate a command. First, the correct module command table has to be found based on the command prefix, and then the corresponding command inside that table is looked for. The second search also starts with index ‘0’ of the command table, and increments that index by ‘1’ until a match is found.
...