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
9242d28c
Commit
9242d28c
authored
Oct 03, 2012
by
Miguel Gómez Sexto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added real read test
Signed-off-by:
Miguel Gomez
<
magomez@igalia.com
>
parent
e633a18d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
test.c
lib/test.c
+21
-4
No files found.
lib/test.c
View file @
9242d28c
...
...
@@ -3,14 +3,16 @@
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <inttypes.h>
#include "libtdc.h"
int
main
(
int
argc
,
char
**
argv
)
{
struct
tdc_board
*
b
;
struct
tdc_time
t
[
10
]
;
struct
tdc_time
t
;
uint32_t
set
,
get
;
int
res
;
int
i
;
b
=
tdc_open
(
1
);
if
(
!
b
)
{
...
...
@@ -117,7 +119,7 @@ int main(int argc, char **argv)
set
=
CHAN0
;
if
(
tdc_set_active_channels
(
b
,
set
))
printf
(
"Error setting active channels
\n
"
);
res
=
tdc_read
(
b
,
6
,
t
,
10
,
O_NONBLOCK
);
res
=
tdc_read
(
b
,
6
,
&
t
,
1
,
O_NONBLOCK
);
if
(
res
==
-
1
&&
errno
==
EINVAL
)
printf
(
"Read from invalid chan OK
\n
"
);
else
...
...
@@ -128,7 +130,7 @@ int main(int argc, char **argv)
set
=
CHAN0
;
if
(
tdc_set_active_channels
(
b
,
set
))
printf
(
"Error setting active channels
\n
"
);
res
=
tdc_read
(
b
,
1
,
t
,
10
,
O_NONBLOCK
);
res
=
tdc_read
(
b
,
1
,
&
t
,
1
,
O_NONBLOCK
);
if
(
res
==
-
1
&&
errno
==
EINVAL
)
printf
(
"Read from disabled chan OK
\n
"
);
else
...
...
@@ -139,12 +141,27 @@ int main(int argc, char **argv)
set
=
CHAN0
;
if
(
tdc_set_active_channels
(
b
,
set
))
printf
(
"Error setting active channels
\n
"
);
res
=
tdc_read
(
b
,
0
,
t
,
10
,
O_NONBLOCK
);
res
=
tdc_read
(
b
,
0
,
&
t
,
1
,
O_NONBLOCK
);
if
(
res
==
-
1
&&
errno
==
EINVAL
)
printf
(
"Read with disabled chans OK
\n
"
);
else
printf
(
"Read with disabled chans wrong
\n
"
);
/* read from valid chan */
tdc_set_host_utc_time
(
b
);
tdc_activate_all_channels
(
b
);
tdc_set_active_channels
(
b
,
CHAN0
);
tdc_set_time_threshold
(
b
,
10
);
for
(
i
=
0
;
i
<
100
;
i
++
)
{
/* this should be a blocking read */
res
=
tdc_read
(
b
,
0
,
&
t
,
1
,
0
);
if
(
res
==
1
)
{
printf
(
"Got sample: utc %"
PRIu64
" ticks %"
PRIu64
" bins %"
PRIu64
" dacapo %i"
,
t
.
utc
,
t
.
ticks
,
t
.
bins
,
t
.
da_capo
);
}
else
{
printf
(
"Error reading sample"
);
}
}
tdc_close
(
b
);
...
...
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