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
fab0932d
Commit
fab0932d
authored
Jul 22, 2015
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib: read last timestamp
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
b94a55ac
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
0 deletions
+48
-0
fmctdc-lib-private.h
lib/fmctdc-lib-private.h
+1
-0
fmctdc-lib.c
lib/fmctdc-lib.c
+45
-0
fmctdc-lib.h
lib/fmctdc-lib.h
+2
-0
No files found.
lib/fmctdc-lib-private.h
View file @
fab0932d
...
...
@@ -28,6 +28,7 @@ struct __fmctdc_board {
int
dev_id
;
char
*
devbase
;
char
*
sysbase
;
int
fdcc
[
FMCTDC_NUM_CHANNELS
];
/**< current controls */
int
fdc
[
5
];
/* The 5 control channels */
int
fdd
[
5
];
/* The 5 data channels */
int
ch_ref
[
FMCTDC_NUM_CHANNELS
];
/**< reference channel */
...
...
lib/fmctdc-lib.c
View file @
fab0932d
...
...
@@ -171,6 +171,7 @@ struct fmctdc_board *fmctdc_open(int offset, int dev_id)
{
struct
__fmctdc_board
*
b
=
NULL
;
uint32_t
nsamples
=
NSAMPLE
;
char
path
[
128
];
int
i
;
if
(
offset
>=
ft_nboards
)
{
...
...
@@ -203,7 +204,20 @@ found:
fmctdc_sysfs_set
(
b
,
"ft-ch4/trigger/post-samples"
,
&
nsamples
);
fmctdc_sysfs_set
(
b
,
"ft-ch5/trigger/post-samples"
,
&
nsamples
);
for
(
i
=
0
;
i
<
FMCTDC_NUM_CHANNELS
;
i
++
)
{
snprintf
(
path
,
sizeof
(
path
),
"%s/ft-ch%d/chan0/current-control"
,
b
->
sysbase
,
i
+
1
);
b
->
fdcc
[
i
]
=
open
(
path
,
O_RDONLY
);
if
(
b
->
fdcc
[
i
]
<
0
)
goto
error
;
}
return
(
void
*
)
b
;
error:
while
(
--
i
)
close
(
b
->
fdcc
[
i
]);
return
NULL
;
}
...
...
@@ -255,6 +269,9 @@ int fmctdc_close(struct fmctdc_board *userb)
if
(
b
->
fdd
[
j
]
>=
0
)
close
(
b
->
fdd
[
j
]);
b
->
fdd
[
j
]
=
-
1
;
if
(
b
->
fdcc
[
j
]
>=
0
)
close
(
b
->
fdcc
[
j
]);
b
->
fdcc
[
j
]
=
-
1
;
}
return
0
;
...
...
@@ -565,6 +582,34 @@ int fmctdc_fileno_channel(struct fmctdc_board *userb, unsigned int channel)
}
/**
* It reads the very last time-stamp produced by a given channel. Note that
* the last time-stamp is the last produced by the hardware and not the last
* read by the user. Between the hardware and the user there is a buffer.
* @param[in] userb TDC board instance token
* @param[in] channel channel to use [0, 4]
* @param[out] t where to write the time-stamps
* @return number of acquired time-stamps, otherwise -1 and errno is set
*/
int
fmctdc_read_last
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
,
struct
fmctdc_time
*
t
)
{
__define_board
(
b
,
userb
);
struct
zio_control
ctrl
;
int
n
;
if
(
channel
>=
FMCTDC_NUM_CHANNELS
)
{
errno
=
EINVAL
;
return
-
1
;
}
n
=
read
(
b
->
fdcc
[
channel
],
&
ctrl
,
sizeof
(
struct
zio_control
));
if
(
n
!=
sizeof
(
struct
zio_control
))
return
-
1
;
return
1
;
}
/**
* It reads a given number of time-stamps from the driver. It will wait at
* most once and return the number of samples that it received from a given
...
...
lib/fmctdc-lib.h
View file @
fab0932d
...
...
@@ -152,6 +152,8 @@ extern int fmctdc_fread(struct fmctdc_board *b, unsigned int channel,
extern
int
fmctdc_fileno_channel
(
struct
fmctdc_board
*
b
,
unsigned
int
channel
);
extern
int
fmctdc_read
(
struct
fmctdc_board
*
b
,
unsigned
int
channel
,
struct
fmctdc_time
*
t
,
int
n
,
int
flags
);
extern
int
fmctdc_read_last
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
,
struct
fmctdc_time
*
t
);
extern
int
fmctdc_flush
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
);
/**@}*/
...
...
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