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
e27613f3
Commit
e27613f3
authored
Sep 12, 2012
by
Miguel Gómez Sexto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated read function and added fread one
Signed-off-by:
Miguel Gomez
<
magomez@igalia.com
>
parent
2ef385bb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
12 deletions
+29
-12
libtdc.c
lib/libtdc.c
+28
-12
libtdc.h
lib/libtdc.h
+1
-0
No files found.
lib/libtdc.c
View file @
e27613f3
...
...
@@ -338,34 +338,37 @@ int tdc_read(struct tdc_board *b, int chan, struct tdc_time *t,
for
(
i
=
0
;
i
<
n
;
)
{
j
=
read
(
fd
,
&
ctrl
,
sizeof
(
ctrl
));
if
(
j
<
0
&&
errno
!=
EAGAIN
)
return
-
1
;
/* one register read */
if
(
j
==
sizeof
(
ctrl
))
{
/* one sample: pick it */
t
->
utc
=
ctrl
.
tstamp
.
secs
;
t
->
ticks
=
ctrl
.
tstamp
.
ticks
;
t
->
bins
=
ctrl
.
tstamp
.
bins
;
t
[
i
].
utc
=
ctrl
.
tstamp
.
secs
;
t
[
i
].
ticks
=
ctrl
.
tstamp
.
ticks
;
t
[
i
].
bins
=
ctrl
.
tstamp
.
bins
;
i
++
;
continue
;
}
/* some bytes read but not complete structure */
if
(
j
>
0
)
{
/* some bytes read but not complete structure */
errno
=
EIO
;
return
-
1
;
}
/* so, it's EAGAIN: if we already got something, we are done */
/* from here on, an error was returned */
/* real error, so exit */
if
(
errno
!=
EAGAIN
)
return
-
1
;
/* EAGAIN: if we already got something, we are done */
if
(
i
)
return
i
;
/* EAGAIN a
t first sample
*/
if
(
j
<
0
&&
flags
==
O_NONBLOCK
)
/* EAGAIN a
nd no data yet. If noblock then return
*/
if
(
flags
==
O_NONBLOCK
)
return
-
1
;
/*
So, first sample and blocking read. Wait..
*/
/*
blocking read
*/
FD_ZERO
(
&
set
);
FD_SET
(
fd
,
&
set
);
if
(
select
(
fd
+
1
,
&
set
,
NULL
,
NULL
,
NULL
)
<
0
)
...
...
@@ -375,3 +378,16 @@ 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
,
n
-
i
,
0
);
if
(
loop
<
0
)
return
-
1
;
i
+=
loop
;
}
return
i
;
}
lib/libtdc.h
View file @
e27613f3
...
...
@@ -46,5 +46,6 @@ extern int tdc_get_active_channels(struct tdc_board *b, uint32_t *config);
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
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