rptun: add rptun ping support
Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
parent
622784be89
commit
f5d2c64556
@ -470,8 +470,8 @@ static const struct cmdmap_s g_cmdmap[] =
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_RPTUN) && !defined(CONFIG_NSH_DISABLE_RPTUN)
|
#if defined(CONFIG_RPTUN) && !defined(CONFIG_NSH_DISABLE_RPTUN)
|
||||||
{ "rptun", cmd_rptun, 2, 4,
|
{ "rptun", cmd_rptun, 2, 6,
|
||||||
"start|stop|reset|panic|dump [dev-path] [value]" },
|
"start|stop|reset|panic|dump|ping [dev-path] [value|times length ack]" },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_NSH_DISABLE_SET
|
#ifndef CONFIG_NSH_DISABLE_SET
|
||||||
|
@ -348,6 +348,7 @@ int cmd_reset_cause(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
|||||||
static int cmd_rptun_once(FAR struct nsh_vtbl_s *vtbl, char *path,
|
static int cmd_rptun_once(FAR struct nsh_vtbl_s *vtbl, char *path,
|
||||||
int argc, char **argv)
|
int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
struct rptun_ping_s ping;
|
||||||
unsigned long val = 0;
|
unsigned long val = 0;
|
||||||
int cmd;
|
int cmd;
|
||||||
int fd;
|
int fd;
|
||||||
@ -377,6 +378,21 @@ static int cmd_rptun_once(FAR struct nsh_vtbl_s *vtbl, char *path,
|
|||||||
{
|
{
|
||||||
cmd = RPTUNIOC_DUMP;
|
cmd = RPTUNIOC_DUMP;
|
||||||
}
|
}
|
||||||
|
else if (strcmp(argv[1], "ping") == 0)
|
||||||
|
{
|
||||||
|
if (argc != 6)
|
||||||
|
{
|
||||||
|
nsh_output(vtbl, g_fmtarginvalid, path);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ping.times = atoi(argv[3]);
|
||||||
|
ping.len = atoi(argv[4]);
|
||||||
|
ping.ack = atoi(argv[5]);
|
||||||
|
|
||||||
|
cmd = RPTUNIOC_PING;
|
||||||
|
val = (unsigned long)&ping;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nsh_output(vtbl, g_fmtarginvalid, argv[1]);
|
nsh_output(vtbl, g_fmtarginvalid, argv[1]);
|
||||||
@ -386,7 +402,7 @@ static int cmd_rptun_once(FAR struct nsh_vtbl_s *vtbl, char *path,
|
|||||||
fd = open(path, 0);
|
fd = open(path, 0);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
nsh_output(vtbl, g_fmtarginvalid, argv[2]);
|
nsh_output(vtbl, g_fmtarginvalid, path);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user