Commit 79a7ebc5 authored by Alessandro Rubini's avatar Alessandro Rubini

tools: added fmc-fdelay-status

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent fbfcd9e9
......@@ -1125,6 +1125,34 @@ options:
@end table
@c ==========================================================================
@node fmc-fdelay-status
@section fmc-fdelay-status
The program reports the current output status of the forur channels.
It receives no arguments besides the usual @t{-i} or @t{-d}. This
is an example of its current output:
@smallexample
spusa.root# ./tools/fmc-fdelay-status
Channel 1, mode already-triggered, repeat 1
start utc 1470, coarse 124999995, frac 929
end utc 1471, coarse 1249995, frac 929
loop utc 1, coarse 0, frac 0
Channel 2, mode already-triggered, repeat 1
start utc 1507, coarse 124999995, frac 945
end utc 1508, coarse 1, frac 945
loop utc 0, coarse 12, frac 2048
Channel 3, mode already-triggered, repeat 1
start utc 3647, coarse 6362495, frac 949
end utc 3647, coarse 124995, frac 949
loop utc 0, coarse 750000, frac 0
Channel 4, mode disable, repeat 1
start utc 0, coarse 0, frac 0
end utc 0, coarse 0, frac 0
loop utc 0, coarse 0, frac 0
@end smallexample
@c ##########################################################################
@node Troubleshooting
@appendix Troubleshooting
......
......@@ -3,4 +3,5 @@ fmc-fdelay-term
fmc-fdelay-board-time
fmc-fdelay-input
fmc-fdelay-pulse
fmc-fdelay-status
......@@ -11,6 +11,7 @@ hostprogs-y += fmc-fdelay-term
hostprogs-y += fmc-fdelay-board-time
hostprogs-y += fmc-fdelay-input
hostprogs-y += fmc-fdelay-pulse
hostprogs-y += fmc-fdelay-status
# we are not in the kernel, so we need to piggy-back on "make modules"
all modules: $(hostprogs-y)
......
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include "fdelay-lib.h"
#include "tools-common.h"
static void help(char *name)
{
fprintf(stderr, "fmc-fdelay-status: reports channel programming\n");
fprintf(stderr, "Use: \"%s [-i <index>] [-d <dev>]\"\n", name);
exit(1);
}
int main(int argc, char **argv)
{
struct fdelay_board *b;
struct fdelay_pulse p;
int nboards, ch, index = -1, dev = -1;
/* Standard part of the file (repeated code) */
if (tools_need_help(argc, argv))
help(argv[0]);
nboards = fdelay_init();
if (nboards < 0) {
fprintf(stderr, "%s: fdelay_init(): %s\n", argv[0],
strerror(errno));
exit(1);
}
if (nboards == 0) {
fprintf(stderr, "%s: no boards found\n", argv[0]);
exit(1);
}
if (nboards == 1)
index = 0; /* so it works with no arguments */
tools_getopt_d_i(argc, argv, &dev, &index);
if (index < 0 && dev < 0) {
fprintf(stderr, "%s: several boards, please pass -i or -d\n",
argv[0]);
exit(1);
}
/* Error if too many arguments */
if (optind != argc)
help(argv[0]);
b = fdelay_open(index, dev);
if (!b) {
fprintf(stderr, "%s: fdelay_open(): %s\n", argv[0],
strerror(errno));
exit(1);
}
for (ch = 1; ch <= 4; ch++) {
if (fdelay_get_config_pulse(b, FDELAY_OUTPUT_USER_TO_HW(ch),
&p) < 0) {
fprintf(stderr, "%s: get_config(channel %i): %s\n",
argv[0], ch, strerror(errno));
}
/* pass hw number again, as the function is low-level */
tools_report_action(FDELAY_OUTPUT_USER_TO_HW(ch), &p);
}
fdelay_close(b);
fdelay_exit();
return 0;
}
......@@ -52,11 +52,16 @@ static inline void report_time(char *name, struct fdelay_time *t)
static inline void tools_report_action(int channel, struct fdelay_pulse *p)
{
char *mode;
char s[80];
if (p->mode == FD_OUT_MODE_DISABLED) mode = "disable";
else if (p->mode == FD_OUT_MODE_PULSE) mode = "pulse";
else if (p->mode == FD_OUT_MODE_DELAY) mode = "delay";
else mode="--wrong-mode--";
else if (p->mode == 0x80) mode = "already-triggered";
else {
sprintf(s, "%i (0x%04x)", p->mode, p->mode);
mode = s;
}
printf("Channel %i, mode %s, repeat %i %s\n",
FDELAY_OUTPUT_HW_TO_USER(channel), mode,
......
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