Commit 810c412c authored by Federico Vaga's avatar Federico Vaga

tools: fmc-tdc-list does not depend on the library

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent c4222c11
......@@ -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:
......
/*
* The fmc-tdc (a.k.a. FmcTdc1ns5cha) library test program.
*
* Copyright (c) 2014-2018 CERN
* Author: Tomasz Włostowski <tomasz.wlostowski@cern.ch>
* Copyright (c) 2014-2020 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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment