Commit 037aa673 authored by Federico Vaga's avatar Federico Vaga

wrtd:tools: improve help message

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 32c70ba7
......@@ -45,36 +45,52 @@ static int wrtd_cmd_log_level(struct wrtd_node *wrtd, int input,
int argc, char *argv[]);
static struct wrtd_commands cmds[] = {
{ "state", "shows input state", wrtd_cmd_state },
{ "enable", "enable the input", wrtd_cmd_enable },
{ "disable", "disable the input", wrtd_cmd_disable },
{ "deadtime", "sets the dead time", wrtd_cmd_set_dead_time },
{ "delay", "sets the input delay", wrtd_cmd_set_delay },
{ "mode", "sets triggering mode", wrtd_cmd_set_mode },
{ "assign", "assigns a trigger", wrtd_cmd_assign },
{ "unassign", "un-assigns the currently assigned trigger", wrtd_cmd_unassign },
{ "arm", "arms the input", wrtd_cmd_arm },
{ "disarm", "disarms the input", wrtd_cmd_disarm },
{ "reset", "resets statistics counters", wrtd_cmd_reset },
{ "swtrig", "sends a software trigger", wrtd_cmd_sw_trigger },
{ "log_level", "set logging level", wrtd_cmd_log_level },
{ "state", "", "shows input state",
wrtd_cmd_state },
{ "enable", "", "enable the input",
wrtd_cmd_enable },
{ "disable", "", "disable the input",
wrtd_cmd_disable },
{ "deadtime", "<number>", "sets the dead time in pico-seconds",
wrtd_cmd_set_dead_time },
{ "delay", "<number>", "sets the input delay in pico-seconds",
wrtd_cmd_set_delay },
{ "mode", "<mode>", "sets triggering mode (see Trigger Modes)",
wrtd_cmd_set_mode },
{ "assign", "<trig-id>", "assigns a trigger (see Trigger ID)",
wrtd_cmd_assign },
{ "unassign", "", "un-assigns the currently assigned trigger",
wrtd_cmd_unassign },
{ "arm", "", "arms the input",
wrtd_cmd_arm },
{ "disarm", "", "disarms the input",
wrtd_cmd_disarm },
{ "reset", "", "resets statistics counters",
wrtd_cmd_reset },
{ "swtrig", "", "sends a software trigger",
wrtd_cmd_sw_trigger },
{ "log_level", "<level>", "set logging level (see Log Levels)",
wrtd_cmd_log_level },
{ NULL }
};
static void help()
{
int i;
fprintf(stderr, "wrtd-tdc-config -D 0x<hex-number> -C <string> -c <number> [cmd-options]\n");
fprintf(stderr, "It configures a channel of a TDC on a white-rabbit trigger distribution node\n");
fprintf(stderr, "-D device id\n");
fprintf(stderr, "-C command name\n");
fprintf(stderr, "-c channel to configure\n");
fprintf(stderr, "\n");
fprintf(stderr, "Available commands:\n");
for(i = 0; cmds[i].handler; i++) {
fprintf(stderr, " %-16s %s\n", cmds[i].name, cmds[i].desc);
}
fprintf(stderr, "\n\n");
fprintf(stderr, "wrtd-in-config -D 0x<hex-number> -C <string> -c <number> [cmd-options]\n\n");
fprintf(stderr, "It configures an input channel on a White-Rabbit Trigger-Distribution node\n\n");
fprintf(stderr, "-D\tdevice id\n");
fprintf(stderr, "-C\tcommand name (see Available commands)\n");
fprintf(stderr, "-c\tchannel to configure [0, %d]\n",
TDC_NUM_CHANNELS - 1);
fprintf(stderr, "\n\n");
help_commands(cmds);
fprintf(stderr, "\n\n");
help_trig_id();
fprintf(stderr, "\n\n");
help_trig_mode();
fprintf(stderr, "\n\n");
help_log_level();
exit(1);
}
......@@ -82,7 +98,7 @@ void dump_input_state(struct wrtd_input_state *state)
{
char tmp[1024], tmp2[1024];
if(!(state->flags & WRTD_ENABLED))
if(!(state->flags & WRTD_ENABLED))
printf("Channel %d: disabled\n", state->input );
decode_flags(tmp,state->flags);
......
......@@ -16,6 +16,43 @@
#include <wrtd-common.h>
#include <wrtd-internal.h>
void help_commands(struct wrtd_commands *cmds)
{
int i;
fprintf(stderr, "Available commands:\n");
for(i = 0; cmds[i].handler; i++) {
fprintf(stderr, " %s %s\n\t%s\n\n",
cmds[i].name, cmds[i].parm, cmds[i].desc);
}
}
void help_log_level()
{
fprintf(stderr, "Log Levels\n");
fprintf(stderr, "You can set more than one log level. Here the list of valid log level strings:\n\n");
fprintf(stderr, "\toff, Raw, Sent, Promiscious, Executed, Missed.\n\n");
fprintf(stderr, "For details about their meaning refer, for example, to the library documentation.\n\n");
}
void help_trig_mode()
{
fprintf(stderr, "Trigger Modes\n");
fprintf(stderr, "You can active only one trigger mode at time. Following the list of valid trigger mode strings:\n\n");
fprintf(stderr, "\tauto, single\n\n");
fprintf(stderr, "For details about their meaning refer, for example, to the library documentation.\n\n");
}
void help_trig_id()
{
fprintf(stderr, "Trigger ID\n");
fprintf(stderr, "The trigger Id is made of 3 number separated by a colon\n\n");
fprintf(stderr, "\t<number>:<number>:<number>\n\n");
fprintf(stderr, "Looking at them from their semantic point of view:\n\n");
fprintf(stderr, "\t<system>:<port>:<trigger>\n\n");
fprintf(stderr, "For details about their meaning refer, for example, to the library documentation.\n\n");
}
void decode_flags(char *buf, uint32_t flags)
{
int l;
......
......@@ -14,6 +14,7 @@
struct wrtd_commands {
const char *name;
const char *parm;
const char *desc;
int (*handler)(struct wrtd_node *wrtd, int line,
int argc, char **argv);
......@@ -23,6 +24,10 @@ struct wrtd_commands {
/**
* @file wrtd-inout-common.c
*/
extern void help_commands(struct wrtd_commands *cmds);
extern void help_log_level();
extern void help_trig_mode();
extern void help_trig_id();
extern void decode_flags(char *buf, uint32_t flags);
extern void decode_mode(char *buf, int mode);
extern void decode_log_level(char *buf, uint32_t flags);
......
......@@ -59,27 +59,48 @@ static int wrtd_cmd_software_trigger(struct wrtd_node *wrtd, int output,
static int wrtd_cmq_has_trig(struct wrtd_node *wrtd, int output,
int argc, char *argv[]);
static struct wrtd_commands cmds[] = {
{ "state", "shows output state", wrtd_cmd_state },
{ "assign", "assigns a trigger", wrtd_cmd_trig_assign },
{ "unassign", "un-assigns a given trigger", wrtd_cmd_trig_unassign },
{ "show", "shows assigned triggers", wrtd_cmd_show },
{ "enable", "enables an output", wrtd_cmd_enable },
{ "disable", "disables an output", wrtd_cmd_disable },
{ "arm", "arms an output", wrtd_cmd_arm },
{ "disarm", "disarm an output", wrtd_cmd_disarm },
{ "mode", "set output mode output", wrtd_cmd_mode },
{ "dead_time", "set output dead time", wrtd_cmd_dead_time },
{ "reset_counters", "reset statistic counters", wrtd_cmd_reset_counters },
{ "log_level", "set log level", wrtd_cmd_log_level },
{ "pulse_width", "sets the output pulse width", wrtd_cmd_pulse_width },
{ "sw_trig", "forces a software trigger", wrtd_cmd_software_trigger },
{ "has_trig", "return true it as a trigger assigned", wrtd_cmq_has_trig},
{ "trig_enable", "enables a particular trigger", wrtd_cmd_trig_enable },
{ "trig_disable", "disables a particular trigger", wrtd_cmd_trig_disable },
{ "trig_stats", "shows per-trigger statistics", wrtd_cmd_trig_stats },
{ "trig_delay", "sets the delay for a particular trigger", wrtd_cmd_trig_delay },
{ "trig_cond_delay", "sets the delay for a particular trigger condition", wrtd_cmd_trig_cond_delay },
{ "trig_find", "retrieves a trigger entry based on its ID", wrtd_cmd_trig_find },
{ "state", "", "shows output state",
wrtd_cmd_state },
{ "assign", "<trig-id> [<trig-id>]", "assigns a trigger (see Trigger ID)",
wrtd_cmd_trig_assign },
{ "unassign", "<trig-id>", "un-assigns a given trigger",
wrtd_cmd_trig_unassign },
{ "show", "", "shows assigned triggers",
wrtd_cmd_show },
{ "enable", "", "enables an output",
wrtd_cmd_enable },
{ "disable", "", "disables an output",
wrtd_cmd_disable },
{ "arm", "", "arms an output",
wrtd_cmd_arm },
{ "disarm", "", "disarm an output",
wrtd_cmd_disarm },
{ "mode", "<mode>", "set output mode output (see Trigger Modes)",
wrtd_cmd_mode },
{ "dead_time", "<number>", "set output dead time in pico-seconds",
wrtd_cmd_dead_time },
{ "reset_counters", "", "reset statistic counters",
wrtd_cmd_reset_counters },
{ "log_level", "<level>", "set log level (see Log Levels)",
wrtd_cmd_log_level },
{ "pulse_width", "<number>", "sets the output pulse width in pico-seconds",
wrtd_cmd_pulse_width },
{ "sw_trig", "", "forces a software trigger",
wrtd_cmd_software_trigger },
{ "has_trig", "", "return true it as a trigger assigned",
wrtd_cmq_has_trig},
{ "trig_enable", "<trig-index>", "enables a particular trigger",
wrtd_cmd_trig_enable },
{ "trig_disable", "<trig-index>", "disables a particular trigger",
wrtd_cmd_trig_disable },
{ "trig_stats", "", "shows per-trigger statistics",
wrtd_cmd_trig_stats },
{ "trig_delay", "<trig-index> <number>", "sets the delay in pico-seconds for a particular trigger ",
wrtd_cmd_trig_delay },
{ "trig_cond_delay", "<trig-index> <number>", "sets the delay in pico-seconds for a particular trigger condition",
wrtd_cmd_trig_cond_delay },
{ "trig_find", "<trig-id>", "retrieves a trigger entry based on its ID",
wrtd_cmd_trig_find },
{ NULL }
};
......@@ -506,16 +527,23 @@ static void help()
{
int i;
fprintf(stderr, "wrtd-out-config -D 0x<hex-number> -C <string> -c <number> [cmd-options]\n");
fprintf(stderr, "Test program for the outputs of a White Rabbit Trigger Distribution node\n");
fprintf(stderr, "-D device id\n");
fprintf(stderr, "-C command name\n");
fprintf(stderr, "-c channel to configure\n");
fprintf(stderr, "\n");
fprintf(stderr, "Available commands:\n");
for(i = 0; cmds[i].handler; i++) {
fprintf(stderr, " %-16s %s\n", cmds[i].name, cmds[i].desc);
}
fprintf(stderr, "\n\n");
fprintf(stderr, "wrtd-out-config -D 0x<hex-number> -C <string> -c <number> [cmd-options]\n\n");
fprintf(stderr, "It configures an output channel on a White Rabbit Trigger-Distribution node\n\n");
fprintf(stderr, "-D\tdevice id\n");
fprintf(stderr, "-C\tcommand name (see Available commands)\n");
fprintf(stderr, "-c\tchannel to configure [0, %d]\n",
FD_NUM_CHANNELS - 1);
fprintf(stderr, "\n\n");
help_commands(cmds);
fprintf(stderr, "\n\n");
help_trig_id();
/* Comple*/
fprintf(stderr, "In order to ease the development of this tool sometimes we refer to a trigger with its index within the real time application. You can get the current trigger index from the 'trig_stats' command\n");
fprintf(stderr, "\n\n");
help_trig_mode();
fprintf(stderr, "\n\n");
help_log_level();
exit(1);
}
......
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