Commit 75b10836 authored by Alessandro Rubini's avatar Alessandro Rubini Committed by Grzegorz Daniluk

shell/cmd_ptp: take over 'mode' command

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent e743b7f6
/*
* This work is part of the White Rabbit project
*
* Copyright (C) 2012 CERN (www.cern.ch)
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* Released according to the GNU GPL, version 2 or any later version.
*/
/* Command: mode
Arguments: PTP mode: gm = grandmaster, master = free-running master, slave = slave
Description: (re)starts/stops the PTP session. */
#include <errno.h>
#include <string.h>
#include <wrc.h>
#include "shell.h"
#include "wrc_ptp.h"
static int cmd_mode(const char *args[])
{
int mode;
static const char *modes[] =
{ "unknown", "grandmaster", "master", "slave" };
if (!strcasecmp(args[0], "gm"))
mode = WRC_MODE_GM;
else if (!strcasecmp(args[0], "master"))
mode = WRC_MODE_MASTER;
else if (!strcasecmp(args[0], "slave"))
mode = WRC_MODE_SLAVE;
else {
pp_printf("%s\n", modes[wrc_ptp_get_mode()]);
return 0;
}
return wrc_ptp_set_mode(mode);
}
DEFINE_WRC_COMMAND(mode) = {
.name = "mode",
.exec = cmd_mode,
};
......@@ -21,6 +21,9 @@ struct subcmd {
{"delay", wrc_ptp_sync_mech, PP_E2E_MECH},
{"p2p", wrc_ptp_sync_mech, PP_P2P_MECH},
{"pdelay", wrc_ptp_sync_mech, PP_P2P_MECH},
{"gm", wrc_ptp_set_mode, WRC_MODE_GM},
{"master", wrc_ptp_set_mode, WRC_MODE_MASTER},
{"slave", wrc_ptp_set_mode, WRC_MODE_SLAVE},
};
static int cmd_ptp(const char *args[])
......@@ -38,3 +41,7 @@ DEFINE_WRC_COMMAND(ptp) = {
.name = "ptp",
.exec = cmd_ptp,
};
DEFINE_WRC_COMMAND(mode) = {
.name = "mode",
.exec = cmd_ptp,
};
......@@ -2,7 +2,6 @@ obj-$(CONFIG_WR_NODE) += \
shell/shell.o \
shell/cmd_version.o \
shell/cmd_ptp.o \
shell/cmd_mode.o \
shell/cmd_help.o \
shell/cmd_mac.o \
shell/cmd_ps.o \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment