Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lfmiao0
rt-thread
提交
f39b44ce
R
rt-thread
项目概览
lfmiao0
/
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,发现更多精彩内容 >>
提交
f39b44ce
编写于
8月 24, 2019
作者:
Lawlieta
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[network][netdev] Improve the ping command error log prompt
Signed-off-by:
chenyong
<
1521761801@qq.com
>
上级
0d8a2162
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
4 deletion
+20
-4
components/net/netdev/src/netdev.c
components/net/netdev/src/netdev.c
+20
-4
未找到文件。
components/net/netdev/src/netdev.c
浏览文件 @
f39b44ce
...
@@ -355,7 +355,7 @@ void netdev_set_default(struct netdev *netdev)
...
@@ -355,7 +355,7 @@ void netdev_set_default(struct netdev *netdev)
/* set default network interface device in the current network stack */
/* set default network interface device in the current network stack */
netdev
->
ops
->
set_default
(
netdev
);
netdev
->
ops
->
set_default
(
netdev
);
}
}
LOG_D
(
"Setting default network interface device name(%s) successfully."
,
netdev
->
name
);
LOG_D
(
"Setting default network interface device name(%s) successfully."
,
netdev
->
name
);
}
}
}
}
...
@@ -1037,16 +1037,30 @@ int netdev_cmd_ping(char* target_name, rt_uint32_t times, rt_size_t size)
...
@@ -1037,16 +1037,30 @@ int netdev_cmd_ping(char* target_name, rt_uint32_t times, rt_size_t size)
{
{
/* using first internet up status network interface device */
/* using first internet up status network interface device */
netdev
=
netdev_get_first_by_flags
(
NETDEV_FLAG_LINK_UP
);
netdev
=
netdev_get_first_by_flags
(
NETDEV_FLAG_LINK_UP
);
if
(
netdev
==
RT_NULL
||
NETDEV_PING_IS_COMMONICABLE
(
netdev
)
==
0
)
if
(
netdev
==
RT_NULL
)
{
{
rt_kprintf
(
"ping: network interface device get error.
\n
"
);
rt_kprintf
(
"ping: not found available network interface device.
\n
"
);
return
-
RT_ERROR
;
}
else
if
(
netdev
->
ops
==
RT_NULL
||
netdev
->
ops
->
ping
==
RT_NULL
)
{
rt_kprintf
(
"ping: network interface device(%s) not support ping feature.
\n
"
,
netdev
->
name
);
return
-
RT_ERROR
;
}
else
if
(
!
netdev_is_up
(
netdev
)
||
!
netdev_is_link_up
(
netdev
))
{
rt_kprintf
(
"ping: network interface device(%s) status error.
\n
"
,
netdev
->
name
);
return
-
RT_ERROR
;
return
-
RT_ERROR
;
}
}
}
}
for
(
index
=
0
;
index
<
times
;
index
++
)
for
(
index
=
0
;
index
<
times
;
index
++
)
{
{
int
delay_tick
=
0
;
rt_tick_t
start_tick
=
0
;
rt_memset
(
&
ping_resp
,
0x00
,
sizeof
(
struct
netdev_ping_resp
));
rt_memset
(
&
ping_resp
,
0x00
,
sizeof
(
struct
netdev_ping_resp
));
start_tick
=
rt_tick_get
();
ret
=
netdev
->
ops
->
ping
(
netdev
,
(
const
char
*
)
target_name
,
size
,
NETDEV_PING_RECV_TIMEO
,
&
ping_resp
);
ret
=
netdev
->
ops
->
ping
(
netdev
,
(
const
char
*
)
target_name
,
size
,
NETDEV_PING_RECV_TIMEO
,
&
ping_resp
);
if
(
ret
==
-
RT_ETIMEOUT
)
if
(
ret
==
-
RT_ETIMEOUT
)
{
{
...
@@ -1073,7 +1087,9 @@ int netdev_cmd_ping(char* target_name, rt_uint32_t times, rt_size_t size)
...
@@ -1073,7 +1087,9 @@ int netdev_cmd_ping(char* target_name, rt_uint32_t times, rt_size_t size)
}
}
}
}
rt_thread_mdelay
(
NETDEV_PING_DELAY
);
/* if the response time is more than NETDEV_PING_DELAY, no nead to delay */
delay_tick
=
((
rt_tick_get
()
-
start_tick
)
>
NETDEV_PING_DELAY
)
||
(
index
==
times
)
?
0
:
NETDEV_PING_DELAY
;
rt_thread_delay
(
delay_tick
);
}
}
return
RT_EOK
;
return
RT_EOK
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录