Commit b0ede37f authored by Adam Wujek's avatar Adam Wujek

shell: add cmd_pps

Signed-off-by: 's avatarAdam Wujek <adam.wujek@creotech.pl>
parent ff324578
...@@ -363,6 +363,14 @@ config LLDP ...@@ -363,6 +363,14 @@ config LLDP
used by network devices for advertising their identity, capabilities, used by network devices for advertising their identity, capabilities,
and neighbors on local area network. and neighbors on local area network.
config CMD_PPS
depends on WR_NODE
boolean "Include PPS command"
default n
help
This enables pps command, which can be used to force PPS output
all the time for all clock classes.
# #
# This is a set of configuration options that should not be changed by # This is a set of configuration options that should not be changed by
# normal users. If the "developer" menu is used, the binary is tainted. # normal users. If the "developer" menu is used, the binary is tainted.
......
/*
* This work is part of the White Rabbit project
*
* Copyright (C) 2021 CERN (www.cern.ch)
* Author: Adam Wujek
*
* Released according to the GNU GPL, version 2 or any later version.
*/
/* Command: pps
Arguments:
force on|off - sets the behaviour of forcing PPS generation
<none> - dumps force PPS generation setting
Description: Enable disable generation of PPS all the time */
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <wrc.h>
#include <wrpc.h>
#include "shell.h"
#include "util.h"
#include "wrc_ptp.h"
char * pps_force_map[] = {
[pps_force_off] = "off",
[pps_force_on] = "on",
};
static int cmd_pps(const char *args[])
{
if (!strcasecmp(args[0], "force")) {
if (!strcasecmp(args[1], "on")) {
wrc_pps_force(pps_force_on);
} else if (!strcasecmp(args[1], "off")) {
wrc_pps_force(pps_force_off);
} else {
return -1;
}
}
pp_printf("PPS force %s\n", pps_force_map[wrc_pps_force(pps_force_check)]);
return 0;
}
DEFINE_WRC_COMMAND(pps) = {
.name = "pps",
.exec = cmd_pps,
};
...@@ -41,6 +41,12 @@ ...@@ -41,6 +41,12 @@
#define KEY_BACKSPACE (127) #define KEY_BACKSPACE (127)
#define KEY_DELETE (126) #define KEY_DELETE (126)
#ifdef CONFIG_CMD_PPS
#define HAS_CMD_PPS 1
#else
#define HAS_CMD_PPS 0
#endif
static char cmd_buf[SH_MAX_LINE_LEN + 1]; static char cmd_buf[SH_MAX_LINE_LEN + 1];
static int cmd_pos = 0, cmd_len = 0; static int cmd_pos = 0, cmd_len = 0;
static int state = SH_PROMPT; static int state = SH_PROMPT;
...@@ -372,5 +378,6 @@ void shell_register_commands(void) ...@@ -372,5 +378,6 @@ void shell_register_commands(void)
REGISTER_WRC_COMMAND(ip); REGISTER_WRC_COMMAND(ip);
if (HAS_VLANS) if (HAS_VLANS)
REGISTER_WRC_COMMAND(vlan); REGISTER_WRC_COMMAND(vlan);
if (HAS_CMD_PPS)
REGISTER_WRC_COMMAND(pps);
} }
...@@ -25,5 +25,6 @@ obj-$(CONFIG_PPSI) += shell/cmd_verbose.o ...@@ -25,5 +25,6 @@ obj-$(CONFIG_PPSI) += shell/cmd_verbose.o
obj-$(CONFIG_CMD_CONFIG) += shell/cmd_config.o obj-$(CONFIG_CMD_CONFIG) += shell/cmd_config.o
obj-$(CONFIG_CMD_SLEEP) += shell/cmd_sleep.o obj-$(CONFIG_CMD_SLEEP) += shell/cmd_sleep.o
obj-$(CONFIG_CMD_LL) += shell/cmd_ll.o obj-$(CONFIG_CMD_LL) += shell/cmd_ll.o
obj-$(CONFIG_CMD_PPS) += shell/cmd_pps.o
obj-$(CONFIG_FLASH_INIT) += shell/cmd_init.o obj-$(CONFIG_FLASH_INIT) += shell/cmd_init.o
obj-$(CONFIG_VLAN) += shell/cmd_vlan.o obj-$(CONFIG_VLAN) += shell/cmd_vlan.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