Commit bacf5df8 authored by Alessandro Rubini's avatar Alessandro Rubini

tools: implement human, float and raw output; used in fdelay-input

Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 12cfcd21
......@@ -1033,18 +1033,35 @@ It receives the following options:
Nonblocking mode: just print what is pending in the buffer.
@item -r
@item -f
Raw output: printf the hex timestamps.
Floating point: print as a floatingpoint seconds.pico value.
The default is a human-readable string, where the decimal part
is split.
@item -f
@item -r
Floading point (human-readable).
This is the default, but the option overrides a
previous ``-r'' if any was there.
Raw output: print the three hardware timestamps, in decimal.
@end table
This an example output, reading a pps signal through a 16ns cable:
@smallexample
spusa.root# ./tools/fmc-fdelay-input -c 3
seq 10921: time 11984:000,000,015,328 ps
seq 10922: time 11985:000,000,015,410 ps
seq 10923: time 11986:000,000,015,248 ps
spusa.root# ./tools/fmc-fdelay-input -c 3 -r
seq 10924: raw utc 11987, coarse 1, frac 3773
seq 10925: raw utc 11988, coarse 1, frac 3814
seq 10926: raw utc 11989, coarse 1, frac 3794
spusa.root# ./tools/fmc-fdelay-input -c 3 -f
seq 10927: time 11990.000000015328
seq 10928: time 11991.000000015410
seq 10929: time 11992.000000015410
@end smallexample
In a future release we'll support reading concurrently from several
boards.
......
......@@ -23,26 +23,13 @@ void help(char *name)
exit(1);
}
void dump_input(struct fdelay_time *t, int np, int israw)
void dump_input(struct fdelay_time *t, int np, int umode)
{
int i;
for (i = 0; i < np; i++, t++) {
uint64_t picoseconds =
(uint64_t) t->coarse * 8000ULL +
(uint64_t) t->frac * 8000ULL / 4096ULL;
printf("seq %5i: ", t->seq_id);
if (israw)
printf("timestamps %016llx %08x %08x\n",
(long long)(t->utc), t->coarse, t->frac);
else
printf ("time %10llu:%03llu,%03llu,%03llu,%03llu ps\n",
(long long)(t->utc),
picoseconds / 1000000000ULL,
(picoseconds / 1000000ULL) % 1000ULL,
(picoseconds / 1000ULL) % 1000ULL,
picoseconds % 1000ULL);
tools_report_time("", t, umode);
}
}
......@@ -54,7 +41,8 @@ int main(int argc, char **argv)
struct fdelay_board *b;
int nboards;
int opt, index = -1, dev = -1;
int nonblock = 0, raw = 0, count = 0;
int nonblock = 0, count = 0;
int umode = TOOLS_UMODE_USER;
/* Standard part of the file (repeated code) */
......@@ -113,11 +101,11 @@ int main(int argc, char **argv)
break;
case 'r':
raw = 1;
umode = TOOLS_UMODE_RAW;
break;
case 'f':
raw = 0;
umode = TOOLS_UMODE_FLOAT;
break;
}
}
......@@ -153,7 +141,7 @@ int main(int argc, char **argv)
if (!ret)
continue;
dump_input(pdata, ret, raw);
dump_input(pdata, ret, umode);
if (nonblock) /* non blocking: nothing more to do */
break;
......
......@@ -50,8 +50,29 @@ int tools_need_help(int argc, char **argv)
void tools_report_time(char *name, struct fdelay_time *t, int umode)
{
printf(" %s utc %10lli, coarse %9li, frac %9li\n",
name, (long long)t->utc, (long)t->coarse, (long)t->frac);
unsigned long long picoseconds =
t->coarse * 8000ULL +
t->frac * 8000ULL / 4096ULL;
printf(" %s ", name);
switch(umode) {
case TOOLS_UMODE_USER:
printf ("time %10llu:%03llu,%03llu,%03llu,%03llu ps\n",
(long long)(t->utc),
(picoseconds / (1000LL * 1000 * 1000)),
(picoseconds / (1000LL * 1000) % 1000),
(picoseconds / (1000LL) % 1000),
(picoseconds % 1000LL));
break;
case TOOLS_UMODE_FLOAT:
printf ("time %10llu.%012llu\n", (long long)(t->utc),
picoseconds);
break;
case TOOLS_UMODE_RAW:
printf(" raw utc %10lli, coarse %9li, frac %9li\n",
(long long)t->utc, (long)t->coarse, (long)t->frac);
break;
}
}
void tools_report_action(int channel, struct fdelay_pulse *p, int umode)
......
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