Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
Beam Positoning Monitor - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Beam Positoning Monitor - Software
Commits
17884ad8
Commit
17884ad8
authored
Aug 27, 2014
by
Lucas Russo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples/*: add examples to read monitoring values
parent
ed4c0708
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
212 additions
and
0 deletions
+212
-0
monit_amp.c
examples/monit_amp.c
+106
-0
monit_pos.c
examples/monit_pos.c
+106
-0
No files found.
examples/monit_amp.c
0 → 100644
View file @
17884ad8
/*
* Simple example demonstrating the communication between
* a client and the FPGA device
*/
#include <mdp.h>
#include <czmq.h>
#include <inttypes.h>
#include <bpm_client.h>
#define DFLT_BIND_FOLDER "/tmp/bpm"
void
print_help
(
char
*
program_name
)
{
printf
(
"Usage: %s [options]
\n
"
"
\t
-h This help message
\n
"
"
\t
-v Verbose output
\n
"
"
\t
-b <broker_endpoint> Broker endpoint
\n
"
,
program_name
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
verbose
=
0
;
char
*
broker_endp
=
NULL
;
char
**
str_p
=
NULL
;
if
(
argc
<
2
)
{
print_help
(
argv
[
0
]);
exit
(
1
);
}
/* FIXME: This is rather buggy! */
/* Simple handling of command-line options. This should be done
* with getopt, for instance*/
int
i
;
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
streq
(
argv
[
i
],
"-v"
))
{
verbose
=
1
;
}
else
if
(
streq
(
argv
[
i
],
"-h"
))
{
print_help
(
argv
[
0
]);
exit
(
1
);
}
else
if
(
streq
(
argv
[
i
],
"-b"
))
{
str_p
=
&
broker_endp
;
}
/* Fallout for options with parameters */
else
{
*
str_p
=
strdup
(
argv
[
i
]);
}
}
/* Set default broker address */
if
(
broker_endp
==
NULL
)
{
broker_endp
=
strdup
(
"ipc://"
DFLT_BIND_FOLDER
);
}
bpm_client_t
*
bpm_client
=
bpm_client_new
(
broker_endp
,
verbose
,
NULL
);
uint32_t
monit_amp
;
bpm_client_err_e
err
=
bpm_get_monit_amp_ch0
(
bpm_client
,
"BPM0:DEVIO:DSP0"
,
&
monit_amp
);
if
(
err
!=
BPM_CLIENT_SUCCESS
){
fprintf
(
stderr
,
"[client:acq]: bpm_get_monit_amp_ch0 failed
\n
"
);
goto
err_get_monit_amp
;
}
fprintf
(
stdout
,
"[client:monit_amp]: monitoring amplitude ch0 = %u
\n
"
,
monit_amp
);
err
=
bpm_get_monit_amp_ch1
(
bpm_client
,
"BPM0:DEVIO:DSP0"
,
&
monit_amp
);
if
(
err
!=
BPM_CLIENT_SUCCESS
){
fprintf
(
stderr
,
"[client:acq]: bpm_get_monit_amp_ch1 failed
\n
"
);
goto
err_get_monit_amp
;
}
fprintf
(
stdout
,
"[client:monit_amp]: monitoring amplitude ch1 = %u
\n
"
,
monit_amp
);
err
=
bpm_get_monit_amp_ch2
(
bpm_client
,
"BPM0:DEVIO:DSP0"
,
&
monit_amp
);
if
(
err
!=
BPM_CLIENT_SUCCESS
){
fprintf
(
stderr
,
"[client:acq]: bpm_get_monit_amp_ch2 failed
\n
"
);
goto
err_get_monit_amp
;
}
fprintf
(
stdout
,
"[client:monit_amp]: monitoring amplitude ch2 = %u
\n
"
,
monit_amp
);
err
=
bpm_get_monit_amp_ch3
(
bpm_client
,
"BPM0:DEVIO:DSP0"
,
&
monit_amp
);
if
(
err
!=
BPM_CLIENT_SUCCESS
){
fprintf
(
stderr
,
"[client:acq]: bpm_get_monit_amp_ch3 failed
\n
"
);
goto
err_get_monit_amp
;
}
fprintf
(
stdout
,
"[client:monit_amp]: monitoring amplitude ch3 = %u
\n
"
,
monit_amp
);
err_get_monit_amp:
bpm_client_destroy
(
&
bpm_client
);
str_p
=
&
broker_endp
;
free
(
*
str_p
);
broker_endp
=
NULL
;
return
0
;
}
examples/monit_pos.c
0 → 100644
View file @
17884ad8
/*
* Simple example demonstrating the communication between
* a client and the FPGA device
*/
#include <mdp.h>
#include <czmq.h>
#include <inttypes.h>
#include <bpm_client.h>
#define DFLT_BIND_FOLDER "/tmp/bpm"
void
print_help
(
char
*
program_name
)
{
printf
(
"Usage: %s [options]
\n
"
"
\t
-h This help message
\n
"
"
\t
-v Verbose output
\n
"
"
\t
-b <broker_endpoint> Broker endpoint
\n
"
,
program_name
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
verbose
=
0
;
char
*
broker_endp
=
NULL
;
char
**
str_p
=
NULL
;
if
(
argc
<
2
)
{
print_help
(
argv
[
0
]);
exit
(
1
);
}
/* FIXME: This is rather buggy! */
/* Simple handling of command-line options. This should be done
* with getopt, for instance*/
int
i
;
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
streq
(
argv
[
i
],
"-v"
))
{
verbose
=
1
;
}
else
if
(
streq
(
argv
[
i
],
"-h"
))
{
print_help
(
argv
[
0
]);
exit
(
1
);
}
else
if
(
streq
(
argv
[
i
],
"-b"
))
{
str_p
=
&
broker_endp
;
}
/* Fallout for options with parameters */
else
{
*
str_p
=
strdup
(
argv
[
i
]);
}
}
/* Set default broker address */
if
(
broker_endp
==
NULL
)
{
broker_endp
=
strdup
(
"ipc://"
DFLT_BIND_FOLDER
);
}
bpm_client_t
*
bpm_client
=
bpm_client_new
(
broker_endp
,
verbose
,
NULL
);
uint32_t
monit_pos
;
bpm_client_err_e
err
=
bpm_get_monit_pos_x
(
bpm_client
,
"BPM0:DEVIO:DSP0"
,
&
monit_pos
);
if
(
err
!=
BPM_CLIENT_SUCCESS
){
fprintf
(
stderr
,
"[client:acq]: bpm_get_monit_pos_x failed
\n
"
);
goto
err_get_monit_pos
;
}
fprintf
(
stdout
,
"[client:monit_pos]: monitoring pos x = %d
\n
"
,
(
int32_t
)
monit_pos
);
err
=
bpm_get_monit_pos_y
(
bpm_client
,
"BPM0:DEVIO:DSP0"
,
&
monit_pos
);
if
(
err
!=
BPM_CLIENT_SUCCESS
){
fprintf
(
stderr
,
"[client:acq]: bpm_get_monit_pos_y failed
\n
"
);
goto
err_get_monit_pos
;
}
fprintf
(
stdout
,
"[client:monit_pos]: monitoring pos y = %d
\n
"
,
(
int32_t
)
monit_pos
);
err
=
bpm_get_monit_pos_q
(
bpm_client
,
"BPM0:DEVIO:DSP0"
,
&
monit_pos
);
if
(
err
!=
BPM_CLIENT_SUCCESS
){
fprintf
(
stderr
,
"[client:acq]: bpm_get_monit_pos_q failed
\n
"
);
goto
err_get_monit_pos
;
}
fprintf
(
stdout
,
"[client:monit_pos]: monitoring pos q = %d
\n
"
,
(
int32_t
)
monit_pos
);
err
=
bpm_get_monit_pos_sum
(
bpm_client
,
"BPM0:DEVIO:DSP0"
,
&
monit_pos
);
if
(
err
!=
BPM_CLIENT_SUCCESS
){
fprintf
(
stderr
,
"[client:acq]: bpm_get_monit_pos_sum failed
\n
"
);
goto
err_get_monit_pos
;
}
fprintf
(
stdout
,
"[client:monit_pos]: monitoring pos sum = %d
\n
"
,
(
int32_t
)
monit_pos
);
err_get_monit_pos:
bpm_client_destroy
(
&
bpm_client
);
str_p
=
&
broker_endp
;
free
(
*
str_p
);
broker_endp
=
NULL
;
return
0
;
}
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