Commit 811ca0a7 authored by Federico Vaga's avatar Federico Vaga

tools: configure the input channel

The tools where assuming that the input is enabled
Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 6733a2c2
......@@ -43,7 +43,7 @@ int main(int argc, char **argv)
struct fdelay_board *b;
int opt, err, dev = -1;
int nonblock = 0, count = 0;
int umode = TOOLS_UMODE_USER;
int umode = TOOLS_UMODE_USER, flags;
/* Standard part of the file (repeated code) */
......@@ -112,6 +112,18 @@ int main(int argc, char **argv)
exit(1);
}
flags = fdelay_get_config_tdc(b);
if (flags < 0) {
err = flags;
goto out;
}
flags &= ~(FD_TDCF_DISABLE_INPUT | FD_TDCF_DISABLE_TSTAMP);
err = fdelay_set_config_tdc(b, flags);
if (err) {
fprintf(stderr, "%s: failed to configure TDC: %s\n", argv[0],
fdelay_strerror(errno));
goto out;
}
/* now read pulses, "np" at a time */
while (1) {
struct fdelay_time pdata[16];
......@@ -121,6 +133,7 @@ int main(int argc, char **argv)
np = count;
ret = fdelay_read(b, pdata, np, nonblock);
if (ret < 0) {
err = ret;
fprintf(stderr, "%s: fdelay_read: %s\n", argv[0],
strerror(errno));
break;
......@@ -141,7 +154,8 @@ int main(int argc, char **argv)
break;
}
out:
fdelay_close(b);
fdelay_exit();
return 0;
return err;
}
......@@ -213,7 +213,7 @@ void parse_width(struct fdelay_pulse *p, char *s)
int main(int argc, char **argv)
{
struct fdelay_board *b;
int i, opt, dev = -1, err = 0;
int i, opt, dev = -1, err = 0, flags;
/* our parameters */
int count = 0, channel = -1;
int trigger_wait = 0, verbose = 0;
......@@ -378,6 +378,19 @@ int main(int argc, char **argv)
report_output_config(channel, &p, TOOLS_UMODE_USER);
flags = fdelay_get_config_tdc(b);
if (flags < 0) {
err = flags;
goto out;
}
flags &= ~FD_TDCF_DISABLE_INPUT;
err = fdelay_set_config_tdc(b, flags);
if (err) {
fprintf(stderr, "%s: failed to configure TDC: %s\n", argv[0],
fdelay_strerror(errno));
goto out;
}
if ((err = fdelay_config_pulse(b, channel, &p)) < 0) {
fprintf(stderr, "%s: fdelay_config_pulse(): %s\n",
argv[0], strerror(-err));
......@@ -394,7 +407,8 @@ int main(int argc, char **argv)
trigger_wait = !i;
}
out:
fdelay_close(b);
fdelay_exit();
return 0;
return err;
}
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