From bcb30277c494e5d994b6e95700a8c52d415575dc Mon Sep 17 00:00:00 2001 From: Alessandro Rubini <rubini@gnudd.com> Date: Thu, 27 Oct 2016 11:55:39 +0200 Subject: [PATCH] shell/cmd_ptp: report current status too Signed-off-by: Alessandro Rubini <rubini@gnudd.com> --- shell/cmd_ptp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/shell/cmd_ptp.c b/shell/cmd_ptp.c index b15b7b933..09c3ea299 100644 --- a/shell/cmd_ptp.c +++ b/shell/cmd_ptp.c @@ -26,11 +26,25 @@ struct subcmd { {"slave", wrc_ptp_set_mode, WRC_MODE_SLAVE}, }; +static char *is_run[] = {"stopped", "running"}; +static char *is_mech[] = {[PP_E2E_MECH] = "e2e", [PP_P2P_MECH] = "p2p"}; +static char *is_mode[] = {[WRC_MODE_GM] = "gm", [WRC_MODE_MASTER] = "master", + [WRC_MODE_SLAVE] = "slave"}; + static int cmd_ptp(const char *args[]) { int i; struct subcmd *c; + + if (!args[0]) { + pp_printf("%s; %s %s\n", + is_run[wrc_ptp_run(-1)], + is_mech[wrc_ptp_sync_mech(-1)], + is_mode[wrc_ptp_get_mode()]); + return 0; + } + for (i = 0, c = subcmd; i < ARRAY_SIZE(subcmd); i++, c++) if (!strcasecmp(args[0], c->name)) return c->fun(c->arg); -- GitLab