Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC TDC 1ns 5cha
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
Commits
810c412c
Commit
810c412c
authored
Jun 15, 2020
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: fmc-tdc-list does not depend on the library
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
c4222c11
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
20 deletions
+59
-20
Makefile
tools/Makefile
+5
-3
fmc-tdc-list.c
tools/fmc-tdc-list.c
+54
-17
No files found.
tools/Makefile
View file @
810c412c
...
...
@@ -11,8 +11,7 @@ REPO_PARENT ?=
DESTDIR
?=
/usr/local/
LIBTDC
=
../lib/
TESTS
=
fmc-tdc-list
\
fmc-tdc-term
\
TESTS
=
fmc-tdc-term
\
fmc-tdc-temperature
\
fmc-tdc-time
\
fmc-tdc-tstamp
\
...
...
@@ -34,14 +33,17 @@ all: $(TESTS)
$(TESTS)
:
$(COMMON_SRCS:.c=.o) $(LIBTDC)/libfmctdc.a
fmc-tdc-list
:
clean
:
rm
-f
$(TESTS)
test-common.o
rm
-f
$(TESTS)
fmc-tdc-list
test-common.o
# make nothing for modules_install, but avoid errors
modules_install
:
install
:
install
-d
$(DESTDIR)
/bin
install
-D
fmc-tdc-list
$(DESTDIR)
/bin
install
-D
$(TESTS)
$(DESTDIR)
/bin
cppcheck
:
...
...
tools/fmc-tdc-list.c
View file @
810c412c
/*
* The fmc-tdc (a.k.a. FmcTdc1ns5cha) library test program.
*
* Copyright (c) 2014-20
18
CERN
* Author:
Tomasz Włostowski <tomasz.wlostowski
@cern.ch>
* Copyright (c) 2014-20
20
CERN
* Author:
Federico Vaga <federico.vaga
@cern.ch>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "test-common.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <glob.h>
#include <getopt.h>
char
git_version
[]
=
"git version: "
GIT_VERSION
;
static
const
char
git_version
[]
=
"git version: "
GIT_VERSION
;
int
main
(
int
argc
,
char
**
argv
)
static
void
help
(
char
*
name
)
{
int
i
;
fprintf
(
stderr
,
"%s: Lists boards
\n
"
"
\t
-V print version
\n
"
"
\t
-V print help
\n
"
,
name
);
}
static
void
print_version
(
char
*
name
)
{
printf
(
"%s %s
\n
"
,
name
,
git_version
);
}
init
(
argc
,
argv
);
int
main
(
int
argc
,
char
**
argv
)
{
glob_t
g
;
int
err
,
i
;
char
opt
;
check_help
(
argc
,
argv
,
1
,
"[-h] [-V]"
,
"lists all installed fmc-tdc boards."
,
""
);
while
((
opt
=
getopt
(
argc
,
argv
,
"hV"
))
!=
-
1
)
{
switch
(
opt
)
{
case
'h'
:
case
'?'
:
help
(
argv
[
0
]);
exit
(
EXIT_SUCCESS
);
break
;
case
'V'
:
print_version
(
argv
[
0
]);
exit
(
EXIT_SUCCESS
);
}
}
printf
(
"Found %i board(s):
\n
"
,
n_boards
);
err
=
glob
(
"/dev/zio/tdc-1n5c-[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]-0-0-ctrl"
,
GLOB_NOSORT
,
NULL
,
&
g
);
if
(
err
==
GLOB_NOMATCH
)
goto
out_glob
;
for
(
i
=
0
;
i
<
n_boards
;
i
++
)
{
struct
__fmctdc_board
*
b
;
struct
fmctdc_board
*
ub
;
for
(
i
=
0
;
i
<
g
.
gl_pathc
;
i
++
)
{
uint32_t
dev_id
;
char
dev_id_str
[
7
]
=
"0x"
;
ub
=
fmctdc_open
(
i
,
-
1
);
b
=
(
typeof
(
b
))
ub
;
printf
(
"%04x, %s, %s
\n
"
,
b
->
dev_id
,
b
->
devbase
,
b
->
sysbase
);
/* Keep only the ID */
strncpy
(
dev_id_str
+
2
,
g
.
gl_pathv
[
i
]
+
strlen
(
"/dev/zio/tdc-1n5c-"
),
4
);
dev_id
=
strtol
(
dev_id_str
,
NULL
,
0
);
printf
(
" FMC-TDC Device ID %04x
\n
"
,
dev_id
);
}
return
0
;
globfree
(
&
g
);
out_glob:
exit
(
err
?
EXIT_FAILURE
:
EXIT_SUCCESS
);
}
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