Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
AdRainty
rt-thread
提交
49e28c26
R
rt-thread
项目概览
AdRainty
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
49e28c26
编写于
9月 03, 2013
作者:
B
Bernard Xiong
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #152 from grissiom/log-trace
log_trace: cleanup
上级
51ce91f3
ea66b820
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
28 deletion
+30
-28
components/utilities/logtrace/log_file.c
components/utilities/logtrace/log_file.c
+30
-19
components/utilities/logtrace/log_trace.c
components/utilities/logtrace/log_trace.c
+0
-9
未找到文件。
components/utilities/logtrace/log_file.c
浏览文件 @
49e28c26
...
...
@@ -41,52 +41,56 @@ struct file_device
static
struct
file_device
_file_device
;
/* common device interface */
rt_err_t
fdevice_open
(
rt_device_t
dev
,
rt_uint16_t
oflag
)
static
rt_err_t
fdevice_open
(
rt_device_t
dev
,
rt_uint16_t
oflag
)
{
int
fd
;
struct
file_device
*
file
=
(
struct
file_device
*
)
dev
;
if
(
file
->
fd
>=
0
)
return
-
RT_EBUSY
;
struct
file_device
*
fdev
=
(
struct
file_device
*
)
dev
;
fd
=
open
(
file
->
filename
,
O_RDONLY
,
0
);
if
(
fdev
->
fd
>=
0
)
return
-
RT_EBUSY
;
/* test and open */
fd
=
open
(
fdev
->
filename
,
O_RDONLY
,
0
);
if
(
fd
>=
0
)
{
close
(
fd
);
/* file exists */
fd
=
open
(
file
->
filename
,
O_WRONLY
|
O_APPEND
,
0
);
fd
=
open
(
fdev
->
filename
,
O_WRONLY
|
O_APPEND
,
0
);
}
else
{
/* file not exists */
fd
=
open
(
f
ile
->
filename
,
O_WRONLY
|
O_CREAT
,
0
);
fd
=
open
(
f
dev
->
filename
,
O_WRONLY
|
O_CREAT
,
0
);
}
fdev
->
fd
=
fd
;
file
->
fd
=
fd
;
return
RT_EOK
;
}
rt_err_t
fdevice_close
(
rt_device_t
dev
)
static
rt_err_t
fdevice_close
(
rt_device_t
dev
)
{
rt_err_t
result
;
struct
file_device
*
fdev
=
(
struct
file_device
*
)
dev
;
struct
file_device
*
file
=
(
struct
file_device
*
)
dev
;
if
(
file
->
fd
<
0
)
return
-
RT_EBUSY
;
if
(
fdev
->
fd
<
0
)
return
-
RT_EBUSY
;
result
=
close
(
f
ile
->
fd
);
result
=
close
(
f
dev
->
fd
);
if
(
result
==
0
)
{
f
ile
->
fd
=
-
1
;
f
dev
->
fd
=
-
1
;
}
return
result
;
}
rt_size_t
fdevice_write
(
rt_device_t
dev
,
rt_off_t
pos
,
const
void
*
buffer
,
rt_size_t
size
)
static
rt_size_t
fdevice_write
(
rt_device_t
dev
,
rt_off_t
pos
,
const
void
*
buffer
,
rt_size_t
size
)
{
struct
file_device
*
file
=
(
struct
file_device
*
)
dev
;
if
(
file
->
fd
<
0
)
return
0
;
struct
file_device
*
fdev
=
(
struct
file_device
*
)
dev
;
if
(
fdev
->
fd
<
0
)
return
0
;
return
write
(
f
ile
->
fd
,
buffer
,
size
);
return
write
(
f
dev
->
fd
,
buffer
,
size
);
}
void
log_trace_file_init
(
const
char
*
filename
)
...
...
@@ -112,4 +116,11 @@ void log_trace_file_init(const char *filename)
_file_device
.
fd
=
-
1
;
}
#endif // RT_USING_DFS
void
log_trace_set_file
(
const
char
*
filename
)
{
log_trace_file_init
(
filename
);
log_trace_set_device
(
"logfile"
);
}
FINSH_FUNCTION_EXPORT_ALIAS
(
log_trace_set_file
,
log_file
,
set
output
filename
of
log
trace
);
#endif
/* RT_USING_DFS */
components/utilities/logtrace/log_trace.c
浏览文件 @
49e28c26
...
...
@@ -416,12 +416,3 @@ rt_err_t log_trace_set_device(const char *device_name)
}
FINSH_FUNCTION_EXPORT_ALIAS
(
log_trace_set_device
,
log_device
,
set
device
of
log
trace
);
#ifdef RT_USING_DFS
void
log_trace_set_file
(
const
char
*
filename
)
{
log_trace_file_init
(
filename
);
log_trace_set_device
(
"logfile"
);
}
FINSH_FUNCTION_EXPORT_ALIAS
(
log_trace_set_file
,
log_file
,
set
output
filename
of
log
trace
);
#endif // RT_USING_DFS
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录