Commit 443e1442 authored by Federico Vaga's avatar Federico Vaga

tools: show buffer statistics

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent a6600f9d
......@@ -31,6 +31,7 @@ static int arg_x_display = 0;
static int arg_trgsw_delay = 0;
static int arg_trgsw = 0;
static int fixup = 0;
static int statistics = 0;
static char git_version[] = "version: " GIT_VERSION;
......@@ -67,6 +68,7 @@ static void fald_help()
">0 from head, <0 from tail\n");
printf(" --graph|-g <chnum> plot the desired channel\n");
printf(" --X11|-X Gnuplot will use X connection\n");
printf(" --stats It prints some statistics\n");
printf(" --version|-V print version information\n");
printf(" --help|-h show this help\n\n");
}
......@@ -91,6 +93,7 @@ static struct option options[] = {
{"timeout", required_argument, 0, 'T'},
{"off-clr", required_argument, 0, FALD_ACQ_OPT_OFF_CLR},
{"fixup", no_argument, &fixup, 1},
{"stats", no_argument, &statistics, 1},
/* new options, to help stress-test */
......@@ -931,6 +934,31 @@ static void fald_acq_plot_data(struct adc_buffer *buf, unsigned int ch)
system(cmd);
}
/**
* It prints data using json format
*/
static void adc_acq_statistics(struct adc_buffer *buf, unsigned int max_chan)
{
int32_t avg;
int i, err;
fprintf(stdout, "{\"statistics\": [");
for (i = 0; i < max_chan; ++i) {
fprintf(stdout, "{ \"chan\": %d", i);
err = adc_buffer_math_avg(buf, i, &avg);
if (err) {
fprintf(stdout, ", \"average\": -1");
} else {
fprintf(stdout, ", \"average\": %"PRId32, avg);
}
if (i == max_chan - 1)
fprintf(stdout, "}");
else
fprintf(stdout, "}, ");
}
fprintf(stdout, "]}\n");
}
/**
* It process the buffer
......@@ -956,6 +984,9 @@ static void fald_acq_process_buffer(struct adc_buffer *buf,
break;
}
if (statistics)
adc_acq_statistics(buf, nchan);
if (arg_plot)
for (w = 0; w < nchan; ++w)
fald_acq_plot_data(buf, w + 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