Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
宁楠萍
rt-thread
提交
d327f4a2
R
rt-thread
项目概览
宁楠萍
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d327f4a2
编写于
10月 22, 2013
作者:
B
Bernard Xiong
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #183 from grissiom/log_trace-in-mem
Log trace in mem
上级
a3bf5e2d
a391e0a8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
56 addition
and
0 deletion
+56
-0
components/drivers/include/rtdevice.h
components/drivers/include/rtdevice.h
+2
-0
components/drivers/src/pipe.c
components/drivers/src/pipe.c
+2
-0
examples/log_trace/memlog.c
examples/log_trace/memlog.c
+52
-0
未找到文件。
components/drivers/include/rtdevice.h
浏览文件 @
d327f4a2
...
...
@@ -114,6 +114,8 @@ struct rt_pipe_device
struct
rt_portal_device
*
read_portal
;
};
#define PIPE_CTRL_GET_SPACE 0x14
/**< get the remaining size of a pipe device */
#define RT_DATAQUEUE_EVENT_UNKNOWN 0x00
#define RT_DATAQUEUE_EVENT_POP 0x01
#define RT_DATAQUEUE_EVENT_PUSH 0x02
...
...
components/drivers/src/pipe.c
浏览文件 @
d327f4a2
...
...
@@ -190,6 +190,8 @@ static rt_size_t rt_pipe_write(rt_device_t dev,
static
rt_err_t
rt_pipe_control
(
rt_device_t
dev
,
rt_uint8_t
cmd
,
void
*
args
)
{
if
(
cmd
==
PIPE_CTRL_GET_SPACE
&&
args
)
*
(
rt_size_t
*
)
args
=
rt_ringbuffer_space_len
(
&
PIPE_DEVICE
(
dev
)
->
ringbuffer
);
return
RT_EOK
;
}
...
...
examples/log_trace/memlog.c
0 → 100644
浏览文件 @
d327f4a2
#include <rtthread.h>
#include <rtdevice.h>
#include <log_trace.h>
#define PIPE_SZ 2048
#define PIPE_NAME "lgpipe"
static
rt_uint8_t
pipebuf
[
PIPE_SZ
];
static
struct
rt_pipe_device
pipedev
;
static
rt_uint8_t
outbuf
[
1024
];
void
memlog_flush
(
void
)
{
rt_size_t
remainsz
,
readsz
;
rt_device_t
console
;
console
=
rt_console_get_device
();
if
(
!
console
)
return
;
rt_device_control
((
rt_device_t
)
&
pipedev
,
PIPE_CTRL_GET_SPACE
,
&
remainsz
);
if
(
remainsz
==
0
)
{
rt_kprintf
(
"logtrace pipe "
PIPE_NAME
" is full, some log may lost
\n
"
);
}
readsz
=
rt_device_read
((
rt_device_t
)
&
pipedev
,
0
,
outbuf
,
sizeof
(
outbuf
));
if
(
readsz
)
rt_device_write
(
console
,
0
,
outbuf
,
readsz
);
}
void
memlog_init
(
void
)
{
rt_err_t
res
;
/* make sure the RT_PIPE_FLAG_BLOCK_RD is not set. The Idle should not be
* blocked. RT_PIPE_FLAG_FORCE_WR will let the pipe discard some old data
* when pipe is full. */
res
=
rt_pipe_init
(
&
pipedev
,
PIPE_NAME
,
RT_PIPE_FLAG_FORCE_WR
,
pipebuf
,
sizeof
(
pipebuf
));
if
(
res
!=
RT_EOK
)
{
rt_kprintf
(
"init pipe device failed: %d
\n
"
,
res
);
return
;
}
log_trace_set_device
(
PIPE_NAME
);
rt_thread_idle_sethook
(
memlog_flush
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录