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
f55e86f9
Commit
f55e86f9
authored
Aug 21, 2018
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: improve printing code
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
45003981
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
14 deletions
+50
-14
fmc-tdc-tstamp.c
tools/fmc-tdc-tstamp.c
+50
-14
No files found.
tools/fmc-tdc-tstamp.c
View file @
f55e86f9
...
@@ -29,22 +29,58 @@ char git_version[] = "git_version: " GIT_VERSION;
...
@@ -29,22 +29,58 @@ char git_version[] = "git_version: " GIT_VERSION;
struct
fmctdc_time
ts_prev
[
FMCTDC_NUM_CHANNELS
];
struct
fmctdc_time
ts_prev
[
FMCTDC_NUM_CHANNELS
];
static
unsigned
int
stop
=
0
,
fmt_wr
=
0
;
static
unsigned
int
stop
=
0
,
fmt_wr
=
0
;
enum
tstamp_print_format
{
TSTAMP_FMT_PS
=
0
,
TSTAMP_FMT_WR
,
};
/**
* It prints the given timestamp using the White-Rabit format
* @param[in] ts timestamp
*
* seconds:coarse:frac
*/
static
inline
void
print_ts_wr
(
struct
fmctdc_time
ts
)
{
fprintf
(
stdout
,
"%10"
PRIu64
":%09u:%04u"
,
ts
.
seconds
,
ts
.
coarse
,
ts
.
frac
);
void
dump_timestamp
(
struct
fmctdc_time
ts
)
}
/**
* It prints the given timestamp using the picosecond format
* @param[in] ts timestamp
*
* seconds.picoseconds
*/
static
inline
void
print_ts_ps
(
struct
fmctdc_time
ts
)
{
{
uint64_t
picoseconds
;
uint64_t
picoseconds
;
if
(
fmt_wr
)
{
picoseconds
=
((
uint64_t
)
ts
.
coarse
)
*
8000ULL
;
/* White rabbit format */
picoseconds
+=
((
uint64_t
)
ts
.
frac
)
*
8000ULL
/
4096ULL
;
fprintf
(
stdout
,
"%10"
PRIu64
":%09u:%04u"
,
fprintf
(
stdout
,
ts
.
seconds
,
ts
.
coarse
,
ts
.
frac
);
"%010"
PRIu64
"s %012"
PRIu64
"ps"
,
return
;
ts
.
seconds
,
picoseconds
);
}
else
{
}
picoseconds
=
(
uint64_t
)
ts
.
coarse
*
8000ULL
+
(
uint64_t
)
ts
.
frac
*
8000ULL
/
4096ULL
;
/**
fprintf
(
stdout
,
* It prints the given timestamp
"%010"
PRIu64
"s %012"
PRIu64
"ps"
,
* @param[in] ts timestamp
ts
.
seconds
,
picoseconds
);
* @param[in] fmt timestamp print format
*/
static
void
print_ts
(
struct
fmctdc_time
ts
,
enum
tstamp_print_format
fmt
)
{
switch
(
fmt
)
{
case
TSTAMP_FMT_WR
:
print_ts_wr
(
ts
);
break
;
case
TSTAMP_FMT_PS
:
print_ts_ps
(
ts
);
break
;
default:
fprintf
(
stdout
,
"--- invalid format ---
\n
"
);
break
;
}
}
}
}
...
@@ -57,7 +93,7 @@ void dump(unsigned int ch, struct fmctdc_time *ts, int diff_mode)
...
@@ -57,7 +93,7 @@ void dump(unsigned int ch, struct fmctdc_time *ts, int diff_mode)
fprintf
(
stdout
,
fprintf
(
stdout
,
"channel %d | channel seq %-12u
\n
ts "
,
"channel %d | channel seq %-12u
\n
ts "
,
ch
,
ts
->
seq_id
);
ch
,
ts
->
seq_id
);
dump_timestamp
(
*
ts
);
print_ts
(
*
ts
,
fmt_wr
);
fprintf
(
stdout
,
"
\n
"
);
fprintf
(
stdout
,
"
\n
"
);
ts_tmp
=
*
ts
;
ts_tmp
=
*
ts
;
...
@@ -71,7 +107,7 @@ void dump(unsigned int ch, struct fmctdc_time *ts, int diff_mode)
...
@@ -71,7 +107,7 @@ void dump(unsigned int ch, struct fmctdc_time *ts, int diff_mode)
/* We are in normal mode, calculate the difference */
/* We are in normal mode, calculate the difference */
fprintf
(
stdout
,
" diff "
);
fprintf
(
stdout
,
" diff "
);
dump_timestamp
(
ts_tmp
);
print_ts
(
ts_tmp
,
fmt_wr
);
ns
=
(
uint64_t
)
ts_tmp
.
coarse
*
8ULL
;
ns
=
(
uint64_t
)
ts_tmp
.
coarse
*
8ULL
;
ns
+=
(
uint64_t
)
(
ts_tmp
.
frac
*
8000ULL
/
4096ULL
)
/
1000ULL
;
ns
+=
(
uint64_t
)
(
ts_tmp
.
frac
*
8000ULL
/
4096ULL
)
/
1000ULL
;
...
...
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