Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
adc-lib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
misc
adc-lib
Commits
443e1442
Commit
443e1442
authored
Oct 15, 2018
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: show buffer statistics
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
a6600f9d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
adc-acq.c
tools/adc-acq.c
+31
-0
No files found.
tools/adc-acq.c
View file @
443e1442
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment