Commit fecd08f3 authored by Federico Vaga's avatar Federico Vaga

tools: make them really generic

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 9050ac83
...@@ -37,8 +37,13 @@ static void fald_acq_stop(struct adc_dev *adc, char *called_from); ...@@ -37,8 +37,13 @@ static void fald_acq_stop(struct adc_dev *adc, char *called_from);
static void fald_help() static void fald_help()
{ {
printf("\nfald-simple-acq [OPTIONS] 0x<device-id>\n\n"); int i;
printf(" <device-id>: FMC identifier (e.g.: \"0x0400\")\n");
printf("\nfald-simple-acq [OPTIONS] <device-name> 0x<device-id>\n\n");
printf(" <device-name>: name of the device to open\n");
for (i = 0; i < __ADC_SUPPORTED_BOARDS_LAST_INDEX; i++)
printf(" %s\n", adc_supported_board_names[i]);
printf(" <device-id>: unique device identifier (e.g.: \"0x0400\")\n");
printf(" --before|-b <num> number of pre samples\n"); printf(" --before|-b <num> number of pre samples\n");
printf(" --after|-a <num> n. of post samples (default: 16)\n"); printf(" --after|-a <num> n. of post samples (default: 16)\n");
printf(" --nshots|-n <num> number of trigger shots\n"); printf(" --nshots|-n <num> number of trigger shots\n");
...@@ -845,6 +850,7 @@ int main(int argc, char *argv[]) ...@@ -845,6 +850,7 @@ int main(int argc, char *argv[])
{ {
struct adc_dev *adc; struct adc_dev *adc;
struct adc_buffer *buf; struct adc_buffer *buf;
char *devname;
int i, err; int i, err;
if (argc == 1) { if (argc == 1) {
...@@ -855,11 +861,13 @@ int main(int argc, char *argv[]) ...@@ -855,11 +861,13 @@ int main(int argc, char *argv[])
} }
/* set local _argv[0] with pg name */ /* set local _argv[0] with pg name */
_argv[0] = argv[0]; _argv[0] = argv[0];
/* devid is the last arg */
/* device name and id are the last two arguments */
devname = argv[argc - 2];
sscanf(argv[argc-1], "%x", &devid); sscanf(argv[argc-1], "%x", &devid);
/* Open the ADC */ /* Open the ADC */
adc = adc_open("fmc-adc-100m14b4cha", devid, adc = adc_open(devname, devid,
/* nshots * (presamples + postsamples) */ /* nshots * (presamples + postsamples) */
/* /*
acq.value[ADC_CONF_ACQ_N_SHOTS] * acq.value[ADC_CONF_ACQ_N_SHOTS] *
......
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
static void fald_help() static void fald_help()
{ {
printf("\nfald-simple-get-conf [OPTIONS] 0x<DEVICE ID>\n\n"); printf("\nfald-simple-get-conf [OPTIONS] <device-name> 0x<device-id>\n\n");
printf(" <DEVICE>: hexadecimal string which represent the device " printf(" <device-name>: name of the device to open\n");
"identificator of an fmc-adc\n"); printf(" <device-id>: unique device identifier (e.g.: \"0x0400\")\n");
printf(" --help|-h: show this help\n\n"); printf(" --help|-h: show this help\n\n");
} }
...@@ -34,7 +34,7 @@ int main(int argc, char *argv[]) ...@@ -34,7 +34,7 @@ int main(int argc, char *argv[])
}; };
int opt_index = 0, err = 0, i; int opt_index = 0, err = 0, i;
unsigned int dev_id = 0; unsigned int dev_id = 0;
char c; char c, *devname;
if (argc == 1) { if (argc == 1) {
fald_help(); fald_help();
...@@ -56,17 +56,18 @@ int main(int argc, char *argv[]) ...@@ -56,17 +56,18 @@ int main(int argc, char *argv[])
} }
if (optind != argc - 1) { if (optind != argc - 1) {
fprintf(stderr, "%s: DEVICE-ID is a mandatory argument\n", fprintf(stderr, "%s: DEVICE-ID and DEVICE-NAME are mandatory arguments\n",
argv[0]); argv[0]);
fald_help(); fald_help();
exit(1); exit(1);
} else { } else {
devname = argv[argc - 2];
sscanf(argv[optind], "0x%x", &dev_id); sscanf(argv[optind], "0x%x", &dev_id);
} }
printf("Open ADC dev_id 0x%04x ...\n", dev_id); printf("Open ADC dev_id 0x%04x ...\n", dev_id);
/* Open the ADC */ /* Open the ADC */
adc = adc_open("adc_100MS_4ch_14bit", dev_id, adc = adc_open(devname, dev_id,
/* no buffers expexted */ 0, 0, /* no buffers expexted */ 0, 0,
/* no flush either */ 0); /* no flush either */ 0);
if (!adc) { if (!adc) {
......
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