Commit ccb12024 authored by Adam Wujek's avatar Adam Wujek 💬

Merge branch 'adam-version'

Add version to libraries and programs.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parents 99e2be2e 0ea7e550
......@@ -12,6 +12,9 @@ REPO_PARENT=../..
ZIO ?= ../zio
ZIO_ABS ?= $(abspath $(ZIO) )
GIT_VERSION := $(shell git describe --dirty --long --tags)
ZIO_GIT_VERSION := $(shell cd $(ZIO_ABS); git describe --dirty --long --tags)
LIB = libfmcadc.a
LOBJ := route.o
LOBJ += init.o
......@@ -21,6 +24,8 @@ LOBJ += buffer-zio.o
LOBJ += lib.o
LOBJ += fmc-adc-100m14b4cha.o
CFLAGS = -Wall -ggdb -O2 -I../kernel -I$(ZIO_ABS)/include $(EXTRACFLAGS)
CFLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""
CFLAGS += -DZIO_GIT_VERSION="\"$(ZIO_GIT_VERSION)\""
LDFLAGS = -L. -lfmcadc
CC ?= $(CROSS_COMPILE)gcc
......
......@@ -190,6 +190,12 @@ extern int fmcadc_release_buffer(struct fmcadc_dev *dev,
extern char *fmcadc_get_driver_type(struct fmcadc_dev *dev);
/* libfmcadc version string */
extern const char * const libfmcadc_version_s;
/* zio version string used during compilation of libfmcadc */
extern const char * const libfmcadc_zio_version_s;
#ifdef __cplusplus
}
#endif
......
......@@ -5,6 +5,9 @@
#include "fmcadc-lib.h"
const char * const libfmcadc_version_s = "libfmcadc version: " GIT_VERSION;
const char * const libfmcadc_zio_version_s = "libfmcadc is using zio version: " ZIO_GIT_VERSION;
/* We currently do nothing in init/exit. We might check /proc/meminfo... */
int fmcadc_init(void)
{
......
......@@ -13,7 +13,13 @@ LIBADC = ../lib/
ZIO ?= ../zio
ZIO_ABS ?= $(abspath $(ZIO) )
GIT_VERSION := $(shell git describe --dirty --long --tags)
ZIO_GIT_VERSION := $(shell cd $(ZIO_ABS); git describe --dirty --long --tags)
CFLAGS = -Wall -g -ggdb -I$(LIBADC) -I$(ZIO_ABS)/include -I../kernel $(EXTRACFLAGS)
CFLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""
CFLAGS += -DZIO_GIT_VERSION="\"$(ZIO_GIT_VERSION)\""
LDFLAGS = -L$(LIBADC)
LDLIBS = -lfmcadc -lpthread -lrt
......
......@@ -33,6 +33,9 @@
#define fald_print_debug(format, ...)
#endif
static char git_version[] = "version: " GIT_VERSION;
static char zio_git_version[] = "zio version: " ZIO_GIT_VERSION;
static void fald_acq_stop(struct fmcadc_dev *adc, char *called_from);
static void fald_help()
......@@ -60,6 +63,7 @@ static void fald_help()
">0 from head, <0 from tail\n");
printf(" --graph|-g <chnum> plot the desired channel\n");
printf(" --X11|-X Gnuplot will use X connection\n");
printf(" --version|-V print version information\n");
printf(" --help|-h show this help\n\n");
}
......@@ -96,11 +100,20 @@ static struct option options[] = {
/* loop for stess test */
{"loop", required_argument, 0, 'l'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
#define GETOPT_STRING "b:a:n:d:u:t:c:T:B:M:N:l:s:r:g:X:p:P:D:he"
#define GETOPT_STRING "b:a:n:d:u:t:c:T:B:M:N:l:s:r:g:X:p:P:D:Vhe"
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
printf("%s %s\n", pname, zio_git_version);
printf("%s\n", libfmcadc_version_s);
printf("%s\n", libfmcadc_zio_version_s);
}
/* variables shared between threads */
unsigned int devid = 0;
......@@ -291,6 +304,9 @@ static void fald_acq_parse_args_and_configure(int argc, char *argv[])
x_display = 1;
fprintf(stdout, "Gnuplot will use X display\n");
break;
case 'V':
print_version(argv[0]);
exit(0);
case 'h': case '?':
fald_help();
......@@ -849,6 +865,22 @@ int main(int argc, char *argv[])
fald_help();
exit(1);
}
/* parsing of arguments is done after fmcadc_open, so we have to check
* here whether we should print help */
if ((argc >= 2) && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))) {
fald_help();
exit(1);
}
/* parsing of arguments is done after fmcadc_open, so we have to check
* here whether we should print version */
if ((argc >= 2) &&
(!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version"))) {
print_version(argv[0]);
exit(0);
}
/* set local _argv[0] with pg name */
_argv[0] = argv[0];
/* devid is the last arg */
......
......@@ -18,6 +18,9 @@
#include <fmcadc-lib.h>
#include <fmc-adc-100m14b4cha.h>
static char git_version[] = "version: " GIT_VERSION;
static char zio_git_version[] = "zio version: " ZIO_GIT_VERSION;
/* Subtract the `struct timespec' values X and Y,
storing the result in RESULT.
Return 1 if the difference is negative, otherwise 0. */
......@@ -51,9 +54,18 @@ static void fald_help()
printf("\nfald-bad-clock [OPTIONS] <devid>\n\n");
printf(" -i <seconds> observation interval\n\n");
printf(" -h show this help\n\n");
printf(" -V show version information\n\n");
exit(1);
}
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
printf("%s %s\n", pname, zio_git_version);
printf("%s\n", libfmcadc_version_s);
printf("%s\n", libfmcadc_zio_version_s);
}
int main (int argc, char *argv[])
{
struct fmcadc_dev *adc;
......@@ -67,7 +79,7 @@ int main (int argc, char *argv[])
memset(&brd_cfg, 0, sizeof(brd_cfg));
brd_cfg.type = FMCADC_CONT_TYPE_BRD;
while ((c = getopt(argc, argv, "i:h")) >= 0) {
while ((c = getopt(argc, argv, "i:hV")) >= 0) {
switch (c) {
case 'i':
err = sscanf(optarg, "%d", &interval);
......@@ -78,6 +90,9 @@ int main (int argc, char *argv[])
case 'h':
fald_help();
break;
case 'V':
print_version(argv[0]);
exit(0);
}
}
......
......@@ -18,6 +18,9 @@
#include <linux/zio-user.h>
#include <fmcadc-lib.h>
static char git_version[] = "version: " GIT_VERSION;
static char zio_git_version[] = "zio version: " ZIO_GIT_VERSION;
static void fald_help()
{
printf("\nfald-simple-acq [OPTIONS] <DEVID>\n\n");
......@@ -35,6 +38,7 @@ static void fald_help()
printf(" --multi-binary|-M <file> save two files per shot: "
"<file>.0000.ctrl etc\n");
printf(" --dont-read|-N config-only, use with zio-dump\n");
printf(" --version|-V print version information\n");
printf(" --help|-h show this help\n\n");
}
......@@ -61,12 +65,21 @@ static struct option options[] = {
{"pre", required_argument, 0, 'p'},
{"post", required_argument, 0, 'P'},
{"decimation", required_argument, 0, 'D'},
{"version", no_argument, 0, 'V'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
#define GETOPT_STRING "b:a:n:d:u:t:c:T:B:M:Np:P:D:h"
#define GETOPT_STRING "b:a:n:d:u:t:c:T:B:M:Np:P:D:Vh"
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
printf("%s %s\n", pname, zio_git_version);
printf("%s\n", libfmcadc_version_s);
printf("%s\n", libfmcadc_zio_version_s);
}
int main(int argc, char *argv[])
{
......@@ -147,6 +160,9 @@ int main(int argc, char *argv[])
case 'N':
binmode = -1;
break;
case 'V':
print_version(argv[0]);
exit(0);
case 'h': case '?':
fald_help();
......
......@@ -17,12 +17,24 @@
#include <linux/zio-user.h>
#include <fmcadc-lib.h>
static char git_version[] = "version: " GIT_VERSION;
static char zio_git_version[] = "zio version: " ZIO_GIT_VERSION;
static void fald_help()
{
printf("\nfald-simple-get-conf [OPTIONS] 0x<DEVICE ID>\n\n");
printf(" <DEVICE>: hexadecimal string which represent the device "
"identificator of an fmc-adc\n");
printf(" --help|-h: show this help\n\n");
printf(" --version|-V: show version information\n");
printf(" --help|-h: show this help\n\n");
}
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
printf("%s %s\n", pname, zio_git_version);
printf("%s\n", libfmcadc_version_s);
printf("%s\n", libfmcadc_zio_version_s);
}
int main(int argc, char *argv[])
......@@ -30,7 +42,8 @@ int main(int argc, char *argv[])
struct fmcadc_dev *adc;
struct fmcadc_conf trg, acq, brd, chn;
static struct option options[] = {
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
int opt_index = 0, err = 0, i;
......@@ -47,8 +60,11 @@ int main(int argc, char *argv[])
acq.mask = 0;
/* Parse options */
while((c = getopt_long(argc, argv, "h", options, &opt_index)) >= 0) {
while((c = getopt_long(argc, argv, "hV", options, &opt_index)) >= 0) {
switch (c) {
case 'V':
print_version(argv[0]);
exit(0);
case 'h':
fald_help();
exit(1);
......
......@@ -18,6 +18,9 @@
#define N_CHAN 4
#define CARD_NAME "fmc-adc-100m14b4cha"
static char git_version[] = "version: " GIT_VERSION;
static char zio_git_version[] = "zio version: " ZIO_GIT_VERSION;
unsigned nshots = 1;
unsigned presamples = 10;
unsigned postsamples = 10;
......@@ -27,6 +30,14 @@ void print_buffer_content(struct fmcadc_buffer *buf);
int read_with_one_buffer(struct fmcadc_dev *dev);
int read_with_n_buffer(struct fmcadc_dev *dev);
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
printf("%s %s\n", pname, zio_git_version);
printf("%s\n", libfmcadc_version_s);
printf("%s\n", libfmcadc_zio_version_s);
}
int main(int argc, char *argv[])
{
unsigned long totalsamples = nshots * (presamples + postsamples);
......@@ -35,9 +46,14 @@ int main(int argc, char *argv[])
struct fmcadc_dev *dev;
int test = 0, err;
if ((argc >= 2) && (!strcmp(argv[1], "-V"))) {
print_version(argv[0]);
exit(0);
}
if (argc != 3) {
fprintf(stderr, "%s: Use \"%s <dev_id> <testnr>\n",
argv[0], argv[1]);
fprintf(stderr, "%s: Use \"%s [-V] <dev_id> <testnr>\n",
argv[0], argv[0]);
exit(1);
}
sscanf(argv[1], "%x", &dev_id);
......
......@@ -9,6 +9,9 @@
#define FALD_TRG_ARGC 2
static char git_version[] = "version: " GIT_VERSION;
static char zio_git_version[] = "zio version: " ZIO_GIT_VERSION;
void send_config(int fd, char *msg)
{
/* removing newline at the end */
......@@ -24,6 +27,12 @@ void send_config(int fd, char *msg)
}
}
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
printf("%s %s\n", pname, zio_git_version);
}
int main(int argc, char *argv[])
{
int i, fd;
......@@ -31,8 +40,13 @@ int main(int argc, char *argv[])
char msg[512], *ptr;
unsigned int devid;
if ((argc >= 2) && (!strcmp(argv[1], "-V"))) {
print_version(argv[0]);
exit(0);
}
if (argc < FALD_TRG_ARGC) {
fprintf(stderr, "\nUsage:\nfald-trg-cfg <dev_id> [options]\n");
fprintf(stderr, "\nUsage:\nfald-trg-cfg [-V] <dev_id> [options]\n");
return -1;
}
......
......@@ -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