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
0300cf4a
Commit
0300cf4a
authored
Oct 01, 2012
by
Miguel Gómez Sexto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed fread and updated read
Signed-off-by:
Miguel Gomez
<
magomez@igalia.com
>
parent
84842d13
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
21 deletions
+39
-21
libtdc.c
lib/libtdc.c
+2
-19
libtdc.h
lib/libtdc.h
+0
-1
test.c
lib/test.c
+37
-1
No files found.
lib/libtdc.c
View file @
0300cf4a
...
...
@@ -370,13 +370,9 @@ int tdc_read(struct tdc_board *b, int chan, struct tdc_time *t,
if
(
errno
!=
EAGAIN
)
return
-
1
;
/* EAGAIN: if we already got something, we are done */
if
(
i
)
return
i
;
/* EAGAIN and no data yet. If noblock then return */
/* EAGAIN: if we can't block, return elements read */
if
(
flags
==
O_NONBLOCK
)
return
-
1
;
return
i
;
/* blocking read */
FD_ZERO
(
&
set
);
...
...
@@ -388,16 +384,3 @@ int tdc_read(struct tdc_board *b, int chan, struct tdc_time *t,
return
i
;
}
int
tdc_fread
(
struct
tdc_board
*
b
,
int
chan
,
struct
tdc_time
*
t
,
int
n
)
{
int
i
,
loop
;
for
(
i
=
0
;
i
<
n
;
)
{
loop
=
tdc_read
(
b
,
chan
,
t
+
i
,
1
,
0
);
if
(
loop
<
0
)
return
-
1
;
i
+=
loop
;
}
return
i
;
}
lib/libtdc.h
View file @
0300cf4a
...
...
@@ -59,6 +59,5 @@ extern int tdc_clear_dacapo_flag(struct tdc_board *b);
extern
int
tdc_read
(
struct
tdc_board
*
b
,
int
chan
,
struct
tdc_time
*
t
,
int
n
,
int
flags
);
extern
int
tdc_fread
(
struct
tdc_board
*
b
,
int
chan
,
struct
tdc_time
*
t
,
int
n
);
#endif
lib/test.c
View file @
0300cf4a
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include "libtdc.h"
int
main
(
int
argc
,
char
**
argv
)
{
struct
tdc_board
*
b
;
struct
tdc_time
t
[
10
];
uint32_t
set
,
get
;
int
res
;
b
=
tdc_open
(
1
);
if
(
!
b
)
{
...
...
@@ -59,7 +62,7 @@ int main(int argc, char **argv)
else
printf
(
"Timestamps threshold functions OK
\n
"
);
/* set/get
active channels with genera
l activation */
/* set/get
channe
l activation */
tdc_activate_all_channels
(
b
);
set
=
CHAN0
|
CHAN2
|
CHAN4
;
if
(
tdc_set_active_channels
(
b
,
set
))
...
...
@@ -109,6 +112,39 @@ int main(int argc, char **argv)
else
printf
(
"Channel activation functions OK
\n
"
);
/* read from invalid chan */
tdc_activate_all_channels
(
b
);
set
=
CHAN0
;
if
(
tdc_set_active_channels
(
b
,
set
))
printf
(
"Error setting active channels
\n
"
);
res
=
tdc_read
(
b
,
6
,
t
,
10
,
O_NONBLOCK
);
if
(
res
==
-
1
&&
errno
==
EINVAL
)
printf
(
"Read from invalid chan OK"
);
else
printf
(
"Reda from invalid chan wrong"
);
/* read from disabled chan */
tdc_activate_all_channels
(
b
);
set
=
CHAN0
;
if
(
tdc_set_active_channels
(
b
,
set
))
printf
(
"Error setting active channels
\n
"
);
res
=
tdc_read
(
b
,
1
,
t
,
10
,
O_NONBLOCK
);
if
(
res
==
-
1
&&
errno
==
EINVAL
)
printf
(
"Read from disabled chan OK"
);
else
printf
(
"Read from disabled chan wrong"
);
/* read with all chans disabled */
tdc_deactivate_all_channels
(
b
);
set
=
CHAN0
;
if
(
tdc_set_active_channels
(
b
,
set
))
printf
(
"Error setting active channels
\n
"
);
res
=
tdc_read
(
b
,
0
,
t
,
10
,
O_NONBLOCK
);
if
(
res
==
-
1
&&
errno
==
EINVAL
)
printf
(
"Read with disabled chans OK"
);
else
printf
(
"Read with disabled chans wrong"
);
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