Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
RT-Thread
rt-thread
提交
b9241041
R
rt-thread
项目概览
RT-Thread
/
rt-thread
大约 1 年 前同步成功
通知
776
Star
8911
Fork
4735
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b9241041
编写于
1月 01, 2014
作者:
B
bernard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add FINSH_USING_MSH_ONLY option
上级
9993c9e6
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
74 addition
and
21 deletion
+74
-21
components/finsh/SConscript
components/finsh/SConscript
+32
-2
components/finsh/cmd.c
components/finsh/cmd.c
+9
-3
components/finsh/msh.c
components/finsh/msh.c
+7
-0
components/finsh/shell.c
components/finsh/shell.c
+24
-16
components/finsh/shell.h
components/finsh/shell.h
+2
-0
未找到文件。
components/finsh/SConscript
浏览文件 @
b9241041
...
...
@@ -2,13 +2,43 @@ Import('rtconfig')
from
building
import
*
cwd
=
GetCurrentDir
()
src
=
Glob
(
'*.c'
)
src
=
Split
(
'''
shell.c
symbol.c
cmd.c
'''
)
fsh_src
=
Split
(
'''
finsh_compiler.c
finsh_error.c
finsh_heap.c
finsh_init.c
finsh_node.c
finsh_ops.c
finsh_parser.c
finsh_var.c
finsh_vm.c
finsh_token.c
'''
)
msh_src
=
Split
(
'''
msh_cmd.c
msh.c
'''
)
CPPPATH
=
[
cwd
]
if
rtconfig
.
CROSS_TOOL
==
'keil'
:
LINKFLAGS
=
' --keep __fsym_* --keep __vsym_* '
LINKFLAGS
=
' --keep __fsym_*'
if
not
GetDepend
(
'FINSH_USING_MSH_ONLY'
):
LINKFLAGS
=
LINKFLAGS
+
' --keep __vsym_* '
else
:
LINKFLAGS
=
''
src
=
src
+
msh_src
if
not
GetDepend
(
'FINSH_USING_MSH_ONLY'
):
src
=
src
+
fsh_src
group
=
DefineGroup
(
'finsh'
,
src
,
depend
=
[
'RT_USING_FINSH'
],
CPPPATH
=
CPPPATH
,
LINKFLAGS
=
LINKFLAGS
)
Return
(
'group'
)
components/finsh/cmd.c
浏览文件 @
b9241041
...
...
@@ -612,9 +612,11 @@ FINSH_FUNCTION_EXPORT(list_mod_detail, list module objects in system)
long
list
(
void
)
{
#ifndef FINSH_USING_MSH_ONLY
struct
finsh_syscall_item
*
syscall_item
;
struct
finsh_sysvar_item
*
sysvar_item
;
#endif
rt_kprintf
(
"--Function List:
\n
"
);
{
struct
finsh_syscall
*
index
;
...
...
@@ -633,6 +635,7 @@ long list(void)
}
}
#ifndef FINSH_USING_MSH_ONLY
/* list syscall list */
syscall_item
=
global_syscall_list
;
while
(
syscall_item
!=
NULL
)
...
...
@@ -662,11 +665,13 @@ long list(void)
rt_kprintf
(
"[l] %s
\n
"
,
sysvar_item
->
sysvar
.
name
);
sysvar_item
=
sysvar_item
->
next
;
}
#endif
return
0
;
}
FINSH_FUNCTION_EXPORT
(
list
,
list
all
symbol
in
system
)
#ifndef FINSH_USING_MSH_ONLY
static
int
str_is_prefix
(
const
char
*
prefix
,
const
char
*
str
)
{
while
((
*
prefix
)
&&
(
*
prefix
==
*
str
))
...
...
@@ -865,8 +870,9 @@ void list_prefix(char *prefix)
rt_strncpy
(
prefix
,
name_ptr
,
min_length
);
}
}
#endif
#if
def FINSH_USING_SYMTAB
#if
defined(FINSH_USING_SYMTAB) && !defined(FINSH_USING_MSH_ONLY)
static
int
dummy
=
0
;
FINSH_VAR_EXPORT
(
dummy
,
finsh_type_int
,
dummy
variable
for
finsh
)
#endif
components/finsh/msh.c
浏览文件 @
b9241041
...
...
@@ -35,6 +35,12 @@
typedef
int
(
*
cmd_function_t
)(
int
argc
,
char
**
argv
);
#ifdef FINSH_USING_MSH
#ifdef FINSH_USING_MSH_ONLY
rt_bool_t
msh_is_used
(
void
)
{
return
RT_TRUE
;
}
#else
#ifdef FINSH_USING_MSH_DEFAULT
static
rt_bool_t
__msh_state
=
RT_TRUE
;
#else
...
...
@@ -61,6 +67,7 @@ static int msh_enter(void)
return
0
;
}
FINSH_FUNCTION_EXPORT_ALIAS
(
msh_enter
,
msh
,
use
module
shell
);
#endif
int
msh_help
(
int
argc
,
char
**
argv
)
{
...
...
components/finsh/shell.c
浏览文件 @
b9241041
...
...
@@ -183,7 +183,6 @@ rt_uint32_t finsh_get_echo()
static
void
shell_auto_complete
(
char
*
prefix
)
{
extern
void
list_prefix
(
char
*
prefix
);
rt_kprintf
(
"
\n
"
);
#ifdef FINSH_USING_MSH
...
...
@@ -194,12 +193,16 @@ static void shell_auto_complete(char* prefix)
else
#endif
{
#ifndef FINSH_USING_MSH_ONLY
extern
void
list_prefix
(
char
*
prefix
);
list_prefix
(
prefix
);
#endif
}
rt_kprintf
(
"%s%s"
,
FINSH_PROMPT
,
prefix
);
}
#ifndef FINSH_USING_MSH_ONLY
void
finsh_run_line
(
struct
finsh_parser
*
parser
,
const
char
*
line
)
{
const
char
*
err_str
;
...
...
@@ -242,6 +245,7 @@ void finsh_run_line(struct finsh_parser* parser, const char *line)
finsh_flush
(
parser
);
}
#endif
#ifdef FINSH_USING_HISTORY
static
rt_bool_t
shell_handle_history
(
struct
finsh_shell
*
shell
)
...
...
@@ -304,7 +308,9 @@ void finsh_thread_entry(void* parameter)
/* normal is echo mode */
shell
->
echo_mode
=
1
;
#ifndef FINSH_USING_MSH_ONLY
finsh_init
(
&
shell
->
parser
);
#endif
rt_kprintf
(
FINSH_PROMPT
);
/* set console device as shell device */
...
...
@@ -480,33 +486,31 @@ void finsh_thread_entry(void* parameter)
/* handle end of line, break */
if
(
ch
==
'\r'
||
ch
==
'\n'
)
{
#ifdef FINSH_USING_MSH
if
(
msh_is_used
()
==
RT_TRUE
&&
shell
->
line_position
!=
0
)
#ifdef FINSH_USING_HISTORY
shell_push_history
(
shell
);
#endif
#ifdef FINSH_USING_MSH
if
(
msh_is_used
()
==
RT_TRUE
)
{
rt_kprintf
(
"
\n
"
);
#ifdef FINSH_USING_HISTORY
shell_push_history
(
shell
);
#endif
msh_exec
(
shell
->
line
,
shell
->
line_position
);
}
else
#endif
#endif
{
#ifndef FINSH_USING_MSH_ONLY
/* add ';' and run the command line */
shell
->
line
[
shell
->
line_position
]
=
';'
;
#ifdef FINSH_USING_HISTORY
shell_push_history
(
shell
);
#endif
if
(
shell
->
line_position
!=
0
)
finsh_run_line
(
&
shell
->
parser
,
shell
->
line
);
else
rt_kprintf
(
"
\n
"
);
#endif
}
rt_kprintf
(
FINSH_PROMPT
);
memset
(
shell
->
line
,
0
,
sizeof
(
shell
->
line
));
shell
->
line_curpos
=
shell
->
line_position
=
0
;
break
;
}
...
...
@@ -605,7 +609,9 @@ int finsh_system_init(void)
extern
const
int
VSymTab
$$
Base
;
extern
const
int
VSymTab
$$
Limit
;
finsh_system_function_init
(
&
FSymTab
$$
Base
,
&
FSymTab
$$
Limit
);
#ifndef FINSH_USING_MSH_ONLY
finsh_system_var_init
(
&
VSymTab
$$
Base
,
&
VSymTab
$$
Limit
);
#endif
#elif defined (__ICCARM__)
/* for IAR Compiler */
finsh_system_function_init
(
__section_begin
(
"FSymTab"
),
__section_end
(
"FSymTab"
));
...
...
@@ -638,15 +644,17 @@ int finsh_system_init(void)
/* create or set shell structure */
#ifdef RT_USING_HEAP
shell
=
(
struct
finsh_shell
*
)
rt_malloc
(
sizeof
(
struct
finsh_shell
));
#else
shell
=
&
_shell
;
#endif
if
(
shell
==
RT_NULL
)
{
rt_kprintf
(
"no memory for shell
\n
"
);
return
-
1
;
}
#else
shell
=
&
_shell
;
#endif
rt_kprintf
(
"shell tcb size: %d
\n
"
,
sizeof
(
struct
finsh_shell
));
memset
(
shell
,
0
,
sizeof
(
struct
finsh_shell
));
rt_sem_init
(
&
(
shell
->
rx_sem
),
"shrx"
,
0
,
0
);
...
...
components/finsh/shell.h
浏览文件 @
b9241041
...
...
@@ -77,7 +77,9 @@ struct finsh_shell
char
cmd_history
[
FINSH_HISTORY_LINES
][
FINSH_CMD_SIZE
];
#endif
#ifndef FINSH_USING_MSH_ONLY
struct
finsh_parser
parser
;
#endif
char
line
[
FINSH_CMD_SIZE
];
rt_uint8_t
line_position
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录