Commit 9b5ff175 authored by Adam Wujek's avatar Adam Wujek 💬

tools: add printing version of the repo

with -V switch
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 97e63f29
......@@ -17,6 +17,8 @@ TESTS = fmc-tdc-list \
fmc-tdc-tstamp
CFLAGS = -I. -I$(LIBTDC) -I../kernel -Wall $(EXTRACFLAGS)
GIT_VERSION := $(shell git describe --dirty --long --tags)
CFLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""
COMMON_SRCS = test-common.c
LDFLAGS = -L$(LIBTDC)
......
......@@ -14,6 +14,8 @@
#include "test-common.h"
char git_version[] = "git version: " GIT_VERSION;
int main(int argc, char **argv)
{
int i;
......@@ -21,7 +23,7 @@ int main(int argc, char **argv)
init(argc, argv);
check_help(argc, argv, 1,
"[-h]", "lists all installed fmc-tdc boards.", "");
"[-h] [-V]", "lists all installed fmc-tdc boards.", "");
printf("Found %i board(s): \n", n_boards);
......
......@@ -13,12 +13,14 @@
#include "test-common.h"
char git_version[] = "git version: " GIT_VERSION;
int main(int argc, char **argv)
{
init(argc, argv);
check_help(argc, argv, 2,
"[-h] <device>",
"[-h] [-V] <device>",
"Displays current temperature of the mezzanine.\n", "");
open_board(argv[1]);
......
......@@ -13,12 +13,14 @@
#include "test-common.h"
char git_version[] = "git version: " GIT_VERSION;
int main(int argc, char **argv)
{
init(argc, argv);
check_help(argc, argv, 2,
"[-h] <device> <channel> [on/off]",
"[-h] [-V] <device> <channel> [on/off]",
"Enables or disables the 50 Ohm termination of a given input channel.\n"
"No on/off command returns the current state of termination resistor.",
"");;
......
......@@ -13,6 +13,8 @@
#include "test-common.h"
char git_version[] = "git version: " GIT_VERSION;
void perror_hint ( const char *func )
{
perror(func);
......@@ -27,7 +29,7 @@ int main(int argc, char **argv)
init(argc, argv);
check_help(argc, argv, 3,
"[-h] <device> <command> [timeval]",
"[-h] [-V] <device> <command> [timeval]",
"Gets/sets the mezzanine TAI time and controls White Rabbit timing.",
"Commands are:\n"
" get - shows current time and White Rabbit status.\n"
......
......@@ -28,6 +28,8 @@
#include "fmctdc-lib.h"
char git_version[] = "git_version: " GIT_VERSION;
/* Previous time stamp for each channel */
struct fmctdc_time ts_prev[FMCTDC_NUM_CHANNELS];
static unsigned int stop = 0, fmt_wr = 0;
......@@ -83,6 +85,15 @@ void dump(unsigned int ch, struct fmctdc_time *ts, int diff_mode)
fprintf(stdout, " [%f Hz]\n", hz);
}
/* We could use print_version from test-common.c, but to avoid creating
* dependencies use local copy */
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
printf("%s\n", libfmctdc_version_s);
printf("%s\n", libfmctdc_zio_version_s);
}
/* Print help message */
static void help(char *name)
{
......@@ -101,6 +112,7 @@ static void help(char *name)
fprintf(stderr, " -l: maximum buffer lenght\n");
fprintf(stderr, " -L:\tkeep reading from the last hardware timestamp instead than from the proper buffer\n");
fprintf(stderr, " -h: print this message\n\n");
fprintf(stderr, " -V: print version info\n\n");
fprintf(stderr, " channels enumerations go from %d to %d \n\n",
FMCTDC_CH_1, FMCTDC_CH_LAST);
}
......@@ -151,13 +163,16 @@ int main(int argc, char **argv)
ref[i] = -1;
/* Parse Options */
while ((opt = getopt(argc, argv, "hwns:d:frm:l:Lc:")) != -1) {
while ((opt = getopt(argc, argv, "hwns:d:frm:l:Lc:V")) != -1) {
switch (opt) {
case 'h':
case '?':
help(argv[0]);
exit(EXIT_SUCCESS);
break;
case 'V':
print_version(argv[0]);
exit(EXIT_SUCCESS);
case 'f':
flush = 1;
break;
......
......@@ -13,6 +13,7 @@
#include "test-common.h"
extern char git_version[];
int n_boards;
struct fmctdc_board *brd = NULL;
......@@ -39,6 +40,13 @@ void open_board(char *dev_id_str)
}
}
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
printf("%s\n", libfmctdc_version_s);
printf("%s\n", libfmctdc_zio_version_s);
}
void check_help(int argc, char **argv, int min_args, char *usage, char *desc,
char *options)
{
......@@ -47,6 +55,9 @@ void check_help(int argc, char **argv, int min_args, char *usage, char *desc,
printf("usage: %s %s\n", argv[0], usage);
printf("%s\n", options);
exit(0);
} else if ((argc >= 2) && (!strcmp(argv[1], "-V"))) {
print_version(argv[0]);
exit(0);
} else if (argc < min_args) {
printf("usage: %s %s\n", argv[0], usage);
exit(0);
......
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