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

Defines

#define FINSH_ERROR_OK   0
#define FINSH_ERROR_INVALID_TOKEN   1
#define FINSH_ERROR_EXPECT_TYPE   2
#define FINSH_ERROR_UNKNOWN_TYPE   3
#define FINSH_ERROR_VARIABLE_EXIST   4
#define FINSH_ERROR_EXPECT_OPERATOR   5
#define FINSH_ERROR_MEMORY_FULL   6
#define FINSH_ERROR_UNKNOWN_OP   7
#define FINSH_ERROR_UNKNOWN_NODE   8
#define FINSH_ERROR_EXPECT_CHAR   9
#define FINSH_ERROR_UNEXPECT_END   10
#define FINSH_ERROR_UNKNOWN_TOKEN   11
#define FINSH_ERROR_NO_FLOAT   12
#define FINSH_ERROR_UNKNOWN_SYMBOL   13
#define FINSH_ERROR_NULL_NODE   14
#define FINSH_FUNCTION_EXPORT(name, desc)
#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc)
#define FINSH_VAR_EXPORT(name, type, desc)

Enumerations

enum  finsh_type {
  finsh_type_unknown = 0, finsh_type_void, finsh_type_voidp, finsh_type_char,
  finsh_type_uchar, finsh_type_charp, finsh_type_short, finsh_type_ushort,
  finsh_type_shortp, finsh_type_int, finsh_type_uint, finsh_type_intp,
  finsh_type_long, finsh_type_ulong, finsh_type_longp
}

Functions

void finsh_syscall_append (const char *name, syscall_func func)
void finsh_sysvar_append (const char *name, u_char type, void *addr)
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 ()

Detailed Description

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.

finsh.png
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).


Define Documentation

#define FINSH_ERROR_OK   0

No error

#define FINSH_ERROR_INVALID_TOKEN   1

Invalid token

#define FINSH_ERROR_EXPECT_TYPE   2

Expect a type

#define FINSH_ERROR_UNKNOWN_TYPE   3

Unknown type

Variable exist

Expect a operator

#define FINSH_ERROR_MEMORY_FULL   6

Memory full

#define FINSH_ERROR_UNKNOWN_OP   7

Unknown operator

#define FINSH_ERROR_UNKNOWN_NODE   8

Unknown node

#define FINSH_ERROR_EXPECT_CHAR   9

Expect a character

#define FINSH_ERROR_UNEXPECT_END   10

Unexpect end

#define FINSH_ERROR_UNKNOWN_TOKEN   11

Unknown token

#define FINSH_ERROR_NO_FLOAT   12

Float not supported

#define FINSH_ERROR_UNKNOWN_SYMBOL   13

Unknown symbol

#define FINSH_ERROR_NULL_NODE   14

Null node

#define FINSH_FUNCTION_EXPORT (   name,
  desc 
)
Value:
const char __fsym_##name##_name[] = #name;                   \
        const char __fsym_##name##_desc[] = #desc;                   \
        const struct finsh_syscall __fsym_##name SECTION("FSymTab")= \
        {                           \
            __fsym_##name##_name,   \
            __fsym_##name##_desc,   \
            (syscall_func)&name     \
        };

This macro exports a system function to finsh shell.

Parameters:
namethe name of function.
descthe description of function, which will show in help.
#define FINSH_FUNCTION_EXPORT_ALIAS (   name,
  alias,
  desc 
)
Value:
const char __fsym_##name##_name[] = #alias;                  \
        const char __fsym_##name##_desc[] = #desc;                   \
        const struct finsh_syscall __fsym_##name SECTION("FSymTab")= \
        {                           \
            __fsym_##name##_name,   \
            __fsym_##name##_desc,   \
            (syscall_func)&name     \
        };

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.
#define FINSH_VAR_EXPORT (   name,
  type,
  desc 
)
Value:
const char __vsym_##name##_name[] = #name;                  \
        const char __vsym_##name##_desc[] = #desc;                  \
        const struct finsh_sysvar __vsym_##name SECTION("VSymTab")= \
        {                           \
            __vsym_##name##_name,   \
            __vsym_##name##_desc,   \
            type,                   \
            (void*)&name            \
        };

This macro exports a variable to finsh shell.

Parameters:
namethe name of function.
typethe type of variable.
descthe description of function, which will show in help.

Enumeration Type Documentation

enum finsh_type

The basic data type in finsh shell

Enumerator:
finsh_type_unknown 

unknown data type

finsh_type_void 

void

finsh_type_voidp 

void pointer

finsh_type_char 

char

finsh_type_uchar 

unsigned char

finsh_type_charp 

char pointer

finsh_type_short 

short

finsh_type_ushort 

unsigned short

finsh_type_shortp 

short pointer

finsh_type_int 

int

finsh_type_uint 

unsigned int

finsh_type_intp 

int pointer

finsh_type_long 

long

finsh_type_ulong 

unsigned long

finsh_type_longp 

long pointer


Function Documentation

void finsh_syscall_append ( const char *  name,
syscall_func  func 
)

This function appends a system call to finsh runtime environment

Parameters:
namethe name of system call
functhe function pointer of system call
void finsh_sysvar_append ( const char *  name,
u_char  type,
void *  addr 
)

This function appends a system variable to finsh runtime environment

Parameters:
namethe name of system variable
typethe data type of system variable
addrthe address of system variable
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.
const char* finsh_get_device ( void  )

This function returns current finsh shell input device.

Returns:
the finsh shell input device name is returned.
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

This function gets the echo mode of finsh shell.

Returns:
the echo mode
 All Data Structures Variables