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
03fb1cce
Commit
03fb1cce
authored
Jan 28, 2015
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: allow to show diff between channels
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
0857702b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
11 deletions
+73
-11
fmctdc-lib-private.h
lib/fmctdc-lib-private.h
+1
-0
fmctdc-lib.c
lib/fmctdc-lib.c
+27
-0
fmctdc-lib.h
lib/fmctdc-lib.h
+2
-1
fmc-tdc-tstamp.c
tools/fmc-tdc-tstamp.c
+43
-10
No files found.
lib/fmctdc-lib-private.h
View file @
03fb1cce
...
@@ -30,6 +30,7 @@ struct __fmctdc_board {
...
@@ -30,6 +30,7 @@ struct __fmctdc_board {
char
*
sysbase
;
char
*
sysbase
;
int
fdc
[
5
];
/* The 5 control channels */
int
fdc
[
5
];
/* The 5 control channels */
int
fdd
[
5
];
/* The 5 data channels */
int
fdd
[
5
];
/* The 5 data channels */
int
ch_ref
[
FMCTDC_NUM_CHANNELS
];
/**< reference channel */
};
};
static
inline
int
fmctdc_is_verbose
(
void
)
static
inline
int
fmctdc_is_verbose
(
void
)
...
...
lib/fmctdc-lib.c
View file @
03fb1cce
...
@@ -548,3 +548,30 @@ extern int fmctdc_check_wr_mode(struct fmctdc_board *userb)
...
@@ -548,3 +548,30 @@ extern int fmctdc_check_wr_mode(struct fmctdc_board *userb)
return
errno
;
return
errno
;
}
}
/**
* It assigns a time reference to a target channel. After you set a reference,
* you will read the difference of between the last reference pulse and the
* target.
* @param[in] userb TDC board instance token
* @param[in] ch_target target channel [1, 5]
* @param[in] ch_reference reference channel [0, 5]. Use 0 to remove reference
* @return 0 on success, otherwise -1 and errno is set appropriately
*/
int
fmctdc_reference_set
(
struct
fmctdc_board
*
userb
,
uint32_t
ch_target
,
uint32_t
ch_reference
)
{
struct
__fmctdc_board
*
b
=
(
void
*
)(
userb
);
char
path
[
64
];
printf
(
"%s:%d
\n
"
,
__func__
,
__LINE__
);
if
(
ch_target
>
FMCTDC_NUM_CHANNELS
||
ch_target
<=
0
)
{
errno
=
EINVAL
;
return
-
1
;
}
printf
(
"%s:%d
\n
"
,
__func__
,
__LINE__
);
snprintf
(
path
,
sizeof
(
path
),
"ft-ch%d/diff-reference"
,
ch_target
);
return
fmctdc_sysfs_set
(
b
,
path
,
&
ch_reference
);
}
lib/fmctdc-lib.h
View file @
03fb1cce
...
@@ -87,7 +87,8 @@ extern int fmctdc_wr_mode(struct fmctdc_board *b, int on);
...
@@ -87,7 +87,8 @@ extern int fmctdc_wr_mode(struct fmctdc_board *b, int on);
extern
int
fmctdc_check_wr_mode
(
struct
fmctdc_board
*
b
);
extern
int
fmctdc_check_wr_mode
(
struct
fmctdc_board
*
b
);
extern
void
fmctdc_ts_sub
(
struct
fmctdc_time
*
a
,
struct
fmctdc_time
*
b
);
extern
void
fmctdc_ts_sub
(
struct
fmctdc_time
*
a
,
struct
fmctdc_time
*
b
);
extern
int
fmctdc_reference_set
(
struct
fmctdc_board
*
userb
,
uint32_t
ch_target
,
uint32_t
ch_reference
);
/**
/**
*@file fmctdc-lib-math.c
*@file fmctdc-lib-math.c
...
...
tools/fmc-tdc-tstamp.c
View file @
03fb1cce
...
@@ -43,15 +43,12 @@ void dump_timestamp(struct fmctdc_time ts, int fmt_wr)
...
@@ -43,15 +43,12 @@ void dump_timestamp(struct fmctdc_time ts, int fmt_wr)
picoseconds
=
(
uint64_t
)
ts
.
coarse
*
8000ULL
+
picoseconds
=
(
uint64_t
)
ts
.
coarse
*
8000ULL
+
(
uint64_t
)
ts
.
frac
*
8000ULL
/
4096ULL
;
(
uint64_t
)
ts
.
frac
*
8000ULL
/
4096ULL
;
fprintf
(
stdout
,
fprintf
(
stdout
,
"%010"
PRIu64
".%03llu,%03llu,%03llu,%03llu ps"
,
"%010"
PRIu64
"s %012llups"
,
ts
.
seconds
,
ts
.
seconds
,
picoseconds
);
picoseconds
/
1000000000ULL
,
(
picoseconds
/
1000000ULL
)
%
1000ULL
,
(
picoseconds
/
1000ULL
)
%
1000ULL
,
picoseconds
%
1000ULL
);
}
}
}
}
void
dump
(
unsigned
int
ch
,
struct
fmctdc_time
*
ts
,
int
fmt_wr
)
void
dump
(
unsigned
int
ch
,
struct
fmctdc_time
*
ts
,
int
fmt_wr
,
int
diff_mode
)
{
{
struct
fmctdc_time
ts_tmp
;
struct
fmctdc_time
ts_tmp
;
uint64_t
ns
;
uint64_t
ns
;
...
@@ -64,6 +61,10 @@ void dump(unsigned int ch, struct fmctdc_time *ts, int fmt_wr)
...
@@ -64,6 +61,10 @@ void dump(unsigned int ch, struct fmctdc_time *ts, int fmt_wr)
ts_tmp
=
*
ts
;
ts_tmp
=
*
ts
;
fmctdc_ts_sub
(
&
ts_tmp
,
&
ts_prev
[
ch
]);
fmctdc_ts_sub
(
&
ts_tmp
,
&
ts_prev
[
ch
]);
if
(
diff_mode
)
return
;
/* We are in normal mode, calculate the difference */
fprintf
(
stdout
,
" diff "
);
fprintf
(
stdout
,
" diff "
);
dump_timestamp
(
ts_tmp
,
fmt_wr
);
dump_timestamp
(
ts_tmp
,
fmt_wr
);
...
@@ -84,6 +85,7 @@ static void help(char *name)
...
@@ -84,6 +85,7 @@ static void help(char *name)
fprintf
(
stderr
,
" -n : non-blocking mode
\n
"
);
fprintf
(
stderr
,
" -n : non-blocking mode
\n
"
);
fprintf
(
stderr
,
" -s n_samples: dump 'n_samples' timestamps
\n
"
);
fprintf
(
stderr
,
" -s n_samples: dump 'n_samples' timestamps
\n
"
);
fprintf
(
stderr
,
" -w : user White Rabbit format
\n
"
);
fprintf
(
stderr
,
" -w : user White Rabbit format
\n
"
);
fprintf
(
stderr
,
" -d <ch>,<ch>: difference between two channel
\n
"
);
fprintf
(
stderr
,
" -h: print this message
\n\n
"
);
fprintf
(
stderr
,
" -h: print this message
\n\n
"
);
}
}
...
@@ -94,6 +96,7 @@ int main(int argc, char **argv)
...
@@ -94,6 +96,7 @@ int main(int argc, char **argv)
unsigned
int
dev_id
;
unsigned
int
dev_id
;
struct
fmctdc_time
ts
;
struct
fmctdc_time
ts
;
int
channels
[
FMCTDC_NUM_CHANNELS
];
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
,
nfds
,
fd
,
byte_read
,
ret
,
n_boards
;
int
nblock
=
0
;
int
nblock
=
0
;
int
n_samples
=
-
1
;
int
n_samples
=
-
1
;
...
@@ -111,9 +114,10 @@ int main(int argc, char **argv)
...
@@ -111,9 +114,10 @@ int main(int argc, char **argv)
exit
(
1
);
exit
(
1
);
}
}
memset
(
ref
,
0
,
sizeof
(
ref
));
/* Parse Options */
/* Parse Options */
while
((
opt
=
getopt
(
argc
,
argv
,
"hwns:"
))
!=
-
1
)
{
while
((
opt
=
getopt
(
argc
,
argv
,
"hwns:
d:
"
))
!=
-
1
)
{
switch
(
opt
)
{
switch
(
opt
)
{
case
'h'
:
case
'h'
:
case
'?'
:
case
'?'
:
...
@@ -129,6 +133,24 @@ int main(int argc, char **argv)
...
@@ -129,6 +133,24 @@ int main(int argc, char **argv)
case
'w'
:
case
'w'
:
fmt_wr
=
1
;
fmt_wr
=
1
;
break
;
break
;
case
'd'
:
sscanf
(
optarg
,
"%i,%i"
,
&
a
,
&
b
);
if
(
a
<
1
||
a
>
FMCTDC_NUM_CHANNELS
)
{
fprintf
(
stderr
,
"%s: invalid reference channel %d
\n
"
,
argv
[
0
],
a
);
help
(
argv
[
0
]);
exit
(
EXIT_FAILURE
);
}
if
(
b
<
0
||
b
>
FMCTDC_NUM_CHANNELS
)
{
fprintf
(
stderr
,
"%s: invalid target channel %d
\n
"
,
argv
[
0
],
b
);
help
(
argv
[
0
]);
exit
(
EXIT_FAILURE
);
}
ref
[
b
-
1
]
=
a
;
break
;
}
}
}
}
if
(
optind
>=
argc
)
{
if
(
optind
>=
argc
)
{
...
@@ -168,9 +190,20 @@ int main(int argc, char **argv)
...
@@ -168,9 +190,20 @@ int main(int argc, char **argv)
}
}
/* If there are not channels, then dump them all */
/* If there are not channels, then dump them all */
if
(
!
chan_count
)
{
if
(
!
chan_count
)
{
for
(
i
=
FMCTDC_CH_1
;
i
<=
FMCTDC_CH_LAST
;
i
++
)
for
(
i
=
FMCTDC_CH_1
;
i
<=
FMCTDC_CH_LAST
;
i
++
)
{
printf
(
"%s:%d
\n
"
,
__func__
,
__LINE__
);
channels
[
i
-
FMCTDC_CH_1
]
=
channels
[
i
-
FMCTDC_CH_1
]
=
fmctdc_fileno_channel
(
brd
,
i
);
fmctdc_fileno_channel
(
brd
,
i
);
ret
=
fmctdc_reference_set
(
brd
,
i
,
ref
[
i
-
1
]);
if
(
ret
)
{
fprintf
(
stderr
,
"%s: cannot set reference mode
\n
"
,
argv
[
0
]);
fprintf
(
stderr
,
"%s: continue in normal mode
\n
"
,
argv
[
0
]);
}
}
chan_count
=
FMCTDC_NUM_CHANNELS
;
chan_count
=
FMCTDC_NUM_CHANNELS
;
}
}
...
@@ -216,7 +249,7 @@ int main(int argc, char **argv)
...
@@ -216,7 +249,7 @@ int main(int argc, char **argv)
byte_read
=
fmctdc_read
(
brd
,
i
,
&
ts
,
1
,
byte_read
=
fmctdc_read
(
brd
,
i
,
&
ts
,
1
,
nblock
?
O_NONBLOCK
:
0
);
nblock
?
O_NONBLOCK
:
0
);
if
(
byte_read
>
0
)
{
if
(
byte_read
>
0
)
{
dump
(
i
,
&
ts
,
fmt_wr
);
dump
(
i
,
&
ts
,
fmt_wr
,
!!
ref
[
i
-
1
]
);
ts_prev
[
i
]
=
ts
;
ts_prev
[
i
]
=
ts
;
n
++
;
n
++
;
...
...
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