Commit 0ea7e550 authored by Adam Wujek's avatar Adam Wujek 💬

tools: add printing version of programs

with -V switch
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent fc911276
......@@ -10,7 +10,9 @@ REPO_PARENT=../..
# user-space tools for spec-fine-delay
DESTDIR ?= /usr/local
GIT_VERSION := $(shell git describe --dirty --long --tags)
CFLAGS += -I../kernel -Wno-trigraphs -Wall -ggdb -O2 $(EXTRACFLAGS)
CFLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""
CC ?= $(CROSS_COMPILE)gcc
......
......@@ -15,6 +15,8 @@
#include <fcntl.h>
#include <errno.h>
static char git_version[] = "version: " GIT_VERSION;
#define buf_len 50
/* user will edit by adding the device name */
char basepath[40] = "/sys/bus/zio/devices/";
......@@ -102,9 +104,15 @@ static void fau_help()
{
printf("\nfau-acq-time [OPTIONS] <DEVICE>\n\n");
printf(" <DEVICE>: ZIO name of the device to use\n");
printf(" --last|-l : time between the last trigger and the acquisition end\n\n");
printf(" --full|-f : time between the acquisition start and the acquisition end\n\n");
printf(" --help|-h: show this help\n\n");
printf(" --last|-l : time between the last trigger and the acquisition end\n");
printf(" --full|-f : time between the acquisition start and the acquisition end\n");
printf(" --version|-V : print version information\n");
printf(" --help|-h : show this help\n\n");
}
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
}
int main(int argc, char *argv[])
......@@ -114,6 +122,7 @@ int main(int argc, char *argv[])
static struct option options[] = {
{"last",no_argument, &last, 1},
{"full",no_argument, &full, 1},
{"version",no_argument, 0, 'V'},
{"help",no_argument, 0, 'h'},
{0, 0, 0, 0}
};
......@@ -126,12 +135,16 @@ int main(int argc, char *argv[])
exit(1);
}
while( (c = getopt_long(argc, argv, "lfh", options, &opt_index)) >=0 ){
while( (c = getopt_long(argc, argv, "lfVh", options, &opt_index)) >=0 ){
if (c == 'h') {
fau_help();
exit(1);
break;
}
if (c == 'V') {
print_version(argv[0]);
exit(1);
}
}
if (optind != argc - 1 ) {
......
......@@ -17,6 +17,8 @@
#include <fcntl.h>
#include <errno.h>
static char git_version[] = "version: " GIT_VERSION;
#define buf_len 50
/* user will edit by adding the device name */
char basepath[40] = "/sys/bus/zio/devices/";
......@@ -89,11 +91,17 @@ static void fau_help()
printf(" --disable-hw-trg: disable the hardware trigger. By default "
"is enabled\n");
printf(" --force: force all attribute to the program default\n");
printf(" --version|-V: print version information\n");
printf(" --help|-h: show this help\n\n");
printf("NOTE: The software trigger works only if also hardware trigger "
"is enabled\n\n");
}
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
}
int main(int argc, char *argv[])
{
/* default attribute */
......@@ -113,6 +121,7 @@ int main(int argc, char *argv[])
{"enable-sw-trg", no_argument, &attrval[FAU_SW_TRG_EN], 1},
{"disable-hw-trg", no_argument, &attrval[FAU_TRG_EN], 0},
{"force", no_argument, &force, 1},
{"version",no_argument, 0, 'V'},
{"help",no_argument, 0, 'h'},
{0, 0, 0, 0}
};
......@@ -124,7 +133,7 @@ int main(int argc, char *argv[])
exit(1);
}
while( (c = getopt_long(argc, argv, "p:P:n:d:t:c:h",
while( (c = getopt_long(argc, argv, "p:P:n:d:t:c:Vh",
options, &opt_index)) >=0 ){
switch(c){
case 'p':
......@@ -145,6 +154,9 @@ int main(int argc, char *argv[])
case 'c':
attrval[FAU_TRG_CHN] = atoi(optarg);
break;
case 'V':
print_version(argv[0]);
exit(1);
case 'h':
fau_help();
exit(1);
......
......@@ -21,6 +21,8 @@
#include <sys/stat.h>
#include <sys/time.h>
static char git_version[] = "version: " GIT_VERSION;
/* Returns the numer of microsecond timer ticks (Tomasz Wlostowski) */
static int64_t get_tics()
{
......@@ -36,11 +38,22 @@ static void delay_to(int64_t until)
;
}
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
}
int main(int argc, char **argv)
{
int fd, addr, count, usec;
int64_t tics;
if ((argc == 2) &&
(!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version"))) {
print_version(argv[0]);
exit(0);
}
if (argc != 4) {
fprintf(stderr,
"%s: Use \"%s <hexaddr> <count> <period-usec>\"\n",
......
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