Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC TDC 1ns 5cha - 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
FMC TDC 1ns 5cha - Software
Commits
598a50d7
Commit
598a50d7
authored
Jul 22, 2015
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: replace select with poll
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
12497f73
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
30 deletions
+12
-30
fmc-tdc-tstamp.c
tools/fmc-tdc-tstamp.c
+12
-30
No files found.
tools/fmc-tdc-tstamp.c
View file @
598a50d7
...
...
@@ -21,6 +21,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <inttypes.h>
#include <poll.h>
#include <signal.h>
#include <getopt.h>
...
...
@@ -117,15 +118,15 @@ int main(int argc, char **argv)
struct
fmctdc_time
ts
;
int
channels
[
FMCTDC_NUM_CHANNELS
];
int
ref
[
FMCTDC_NUM_CHANNELS
],
a
,
b
;
int
chan_count
=
0
,
i
,
n
,
ch
,
nfds
,
fd
,
byte_read
,
ret
,
n_boards
;
int
chan_count
=
0
,
i
,
n
,
ch
,
fd
,
byte_read
,
ret
,
n_boards
;
int
nblock
=
0
,
buflen
=
16
;
enum
fmctdc_buffer_mode
bufmode
=
FMCTDC_BUFFER_FIFO
;
int
n_samples
=
-
1
;
int
fmt_wr
=
0
,
flush
=
0
,
read
=
0
,
last
=
0
;
char
opt
;
fd_set
rfds
;
struct
sigaction
new_action
,
old_action
;
int
ch_valid
[
FMCTDC_NUM_CHANNELS
]
=
{
0
,
1
,
2
,
3
,
4
};
struct
pollfd
p
[
FMCTDC_NUM_CHANNELS
];
/* Set up the structure to specify the new action. */
new_action
.
sa_handler
=
termination_handler
;
...
...
@@ -248,6 +249,10 @@ int main(int argc, char **argv)
}
channels
[
ch
]
=
fmctdc_fileno_channel
(
brd
,
ch
);
p
[
ch
].
fd
=
channels
[
ch
];
p
[
ch
].
events
=
POLLIN
|
POLLERR
;
ret
=
fmctdc_reference_set
(
brd
,
ch
,
ref
[
ch
]);
if
(
ret
)
{
fprintf
(
stderr
,
...
...
@@ -287,32 +292,10 @@ int main(int argc, char **argv)
/* Read Time-Stamps */
n
=
0
;
while
((
n
<
n_samples
||
n_samples
<=
0
)
&&
(
!
stop
))
{
/* Check for pending signal */
nfds
=
0
;
/* Prepare the list of channel to observe */
FD_ZERO
(
&
rfds
);
for
(
i
=
0
;
i
<=
FMCTDC_CH_LAST
;
i
++
)
{
fd
=
channels
[
i
];
if
(
fd
<
0
)
{
fprintf
(
stderr
,
"Can't open channel %d
\n
"
,
i
);
exit
(
EXIT_FAILURE
);
}
else
{
FD_SET
(
fd
,
&
rfds
);
nfds
=
fd
>
nfds
?
fd
:
nfds
;
}
}
/* non-blocking mode: do nothing, otherwise wait until one
of the channels becomes active */
ret
=
select
(
nfds
+
1
,
&
rfds
,
NULL
,
NULL
,
NULL
);
if
(
!
nblock
&&
ret
<=
0
)
{
if
(
ret
<
0
)
fprintf
(
stderr
,
"Error while waiting for timestamp: %s
\n
"
,
strerror
(
errno
));
continue
;
if
(
!
nblock
)
{
ret
=
poll
(
p
,
FMCTDC_NUM_CHANNELS
,
10
);
if
(
ret
<=
0
)
continue
;
}
/* Now we can read the timestamp */
...
...
@@ -321,9 +304,8 @@ int main(int argc, char **argv)
if
(
fd
<
0
)
continue
;
if
(
!
(
nblock
||
FD_ISSET
(
fd
,
&
rfds
)
))
if
(
!
(
p
[
ch_valid
[
i
]].
revents
&
POLLIN
))
continue
;
byte_read
=
fmctdc_read
(
brd
,
i
,
&
ts
,
1
,
nblock
?
O_NONBLOCK
:
0
);
if
(
byte_read
>
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