RT-Thread RTOS  1.2.0
An open source embedded real-time operating system
finsh shell

Macros

#define FINSH_FUNCTION_EXPORT(name, desc)
 
#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc)
 
#define MSH_CMD_EXPORT(...)
 
#define MSH_CMD_EXPORT_ALIAS(...)
 

Functions

rt_uint32_t finsh_get_prompt_mode (void)
 
void finsh_set_prompt_mode (rt_uint32_t prompt_mode)
 
void finsh_set_device (const char *device_name)
 
const char * finsh_get_device ()
 
void finsh_set_echo (rt_uint32_t echo)
 
rt_uint32_t finsh_get_echo ()
 
void finsh_thread_entry_sethook (void(*hook)(void))
 

Detailed Description

finsh shell is a user command shell in RT-Thread RTOS.

finsh shell is a user command shell in RT-Thread RTOS, which is a shell can accept C-expression like syntax in command. From finsh shell, user can access system area, such as memory, variables and function by input C-expression in command.

Figure 3: finsh shell architecture

There is a shell thread, which named as "tshell", in the finsh shell, it read user command from console device, and then invokes system function or access system variable to output result (by rt_kprintf).

Macro Definition Documentation

◆ FINSH_FUNCTION_EXPORT

#define FINSH_FUNCTION_EXPORT (   name,
  desc 
)

This macro exports a system function to finsh shell.

Parameters
namethe name of function.
descthe description of function, which will show in help.

◆ FINSH_FUNCTION_EXPORT_ALIAS

#define FINSH_FUNCTION_EXPORT_ALIAS (   name,
  alias,
  desc 
)

This macro exports a system function with an alias name to finsh shell.

Parameters
namethe name of function.
aliasthe alias name of function.
descthe description of function, which will show in help.

◆ MSH_CMD_EXPORT

#define MSH_CMD_EXPORT (   ...)
Value:
__MSH_GET_MACRO(__VA_ARGS__, _MSH_FUNCTION_CMD2_OPT, \
_MSH_FUNCTION_CMD2)(__VA_ARGS__)

This macro exports a command to module shell.

param command is the name of the command. param desc is the description of the command, which will show in help list. param opt This is an option, enter any content to enable option completion

◆ MSH_CMD_EXPORT_ALIAS

#define MSH_CMD_EXPORT_ALIAS (   ...)
Value:
__MSH_GET_EXPORT_MACRO(__VA_ARGS__, _MSH_FUNCTION_EXPORT_CMD3_OPT, \
_MSH_FUNCTION_EXPORT_CMD3)(__VA_ARGS__)

This macro exports a command with alias to module shell.

param command is the name of the command. param alias is the alias of the command. param desc is the description of the command, which will show in help list. param opt This is an option, enter any content to enable option completion

#define MSH_CMD_EXPORT_ALIAS(command, alias, desc) or
#define MSH_CMD_EXPORT_ALIAS(command, alias, desc, opt)

Function Documentation

◆ finsh_get_prompt_mode()

rt_uint32_t finsh_get_prompt_mode ( void  )

This function get the prompt mode of finsh shell.

Returns
prompt the prompt mode, 0 disable prompt mode, other values enable prompt mode.

◆ finsh_set_prompt_mode()

void finsh_set_prompt_mode ( rt_uint32_t  prompt_mode)

This function set the prompt mode of finsh shell.

The parameter 0 disable prompt mode, other values enable prompt mode.

Parameters
prompt_modethe prompt mode

◆ finsh_set_device()

void finsh_set_device ( const char *  device_name)

This function sets the input device of finsh shell.

Parameters
device_namethe name of new input device.

◆ finsh_get_device()

const char* finsh_get_device ( void  )

This function returns current finsh shell input device.

Returns
the finsh shell input device name is returned.

◆ finsh_set_echo()

void finsh_set_echo ( rt_uint32_t  echo)

This function set the echo mode of finsh shell.

FINSH_OPTION_ECHO=0x01 is echo mode, other values are none-echo mode.

Parameters
echothe echo mode

◆ finsh_get_echo()

rt_uint32_t finsh_get_echo ( void  )

This function gets the echo mode of finsh shell.

Returns
the echo mode

◆ finsh_thread_entry_sethook()

void finsh_thread_entry_sethook ( void(*)(void)  hook)

This function set a hook function at the entry of finsh thread.

Parameters
hookthe function point to be called