Commit f7f2eb9f authored by Lucas Russo's avatar Lucas Russo

examples/trigger.c: add rcv/trn length options

parent dddd7b18
...@@ -32,12 +32,14 @@ static struct option long_options[] = ...@@ -32,12 +32,14 @@ static struct option long_options[] =
{"rcvsel", required_argument, NULL, 'p'}, {"rcvsel", required_argument, NULL, 'p'},
{"transmsrc", required_argument, NULL, 't'}, {"transmsrc", required_argument, NULL, 't'},
{"transsel", required_argument, NULL, 'u'}, {"transsel", required_argument, NULL, 'u'},
{"rcvlen", required_argument, NULL, 'l'},
{"trnlen", required_argument, NULL, 'm'},
{"dir", required_argument, NULL, 'd'}, {"dir", required_argument, NULL, 'd'},
{"dirpol", required_argument, NULL, 'x'}, {"dirpol", required_argument, NULL, 'x'},
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
static const char* shortopt = "hb:vo:s:c:r:p:t:u:d:x:"; static const char* shortopt = "hb:vo:s:c:r:p:t:u:l:m:d:x:";
void print_help (char *program_name) void print_help (char *program_name)
{ {
...@@ -63,6 +65,9 @@ void print_help (char *program_name) ...@@ -63,6 +65,9 @@ void print_help (char *program_name)
" -p --rcvsel <Receive selection source for the selected channel = [TBD]> \n" " -p --rcvsel <Receive selection source for the selected channel = [TBD]> \n"
" -t --transmsrc <Transmit source for the selected channel = [0 = trigger backplane, 1 = FPGA internal]> \n" " -t --transmsrc <Transmit source for the selected channel = [0 = trigger backplane, 1 = FPGA internal]> \n"
" -u --transmsel <Transmit selection source for the selected channel = [TBD]> \n" " -u --transmsel <Transmit selection source for the selected channel = [TBD]> \n"
" -l --rcvlen <Receive debounce length> \n"
" -m --trnlen <Transmit extension length> \n"
" -d --dir <Trigger direction = [0 = FPGA Output, 1 = FPGA Input]> \n" " -d --dir <Trigger direction = [0 = FPGA Output, 1 = FPGA Input]> \n"
" -x --dirpol <Trigger direction polarity = [0 = Polarity unchanged, 1 = Polarity reversed]> \n", " -x --dirpol <Trigger direction polarity = [0 = Polarity unchanged, 1 = Polarity reversed]> \n",
program_name); program_name);
...@@ -85,6 +90,10 @@ int main (int argc, char *argv []) ...@@ -85,6 +90,10 @@ int main (int argc, char *argv [])
int transmsrc_sel = 0; int transmsrc_sel = 0;
char *transmsel_str = NULL; char *transmsel_str = NULL;
int transmsel_sel = 0; int transmsel_sel = 0;
char *rcvlen_str = NULL;
int rcvlen_sel = 0;
char *trnlen_str = NULL;
int trnlen_sel = 0;
char *dir_str = NULL; char *dir_str = NULL;
int dir_sel = 0; int dir_sel = 0;
char *dirpol_str = NULL; char *dirpol_str = NULL;
...@@ -141,6 +150,16 @@ int main (int argc, char *argv []) ...@@ -141,6 +150,16 @@ int main (int argc, char *argv [])
transmsel_sel = 1; transmsel_sel = 1;
break; break;
case 'l':
rcvlen_str = strdup (optarg);
rcvlen_sel = 1;
break;
case 'm':
trnlen_str = strdup (optarg);
trnlen_sel = 1;
break;
case 'd': case 'd':
dir_str = strdup (optarg); dir_str = strdup (optarg);
dir_sel = 1; dir_sel = 1;
...@@ -285,6 +304,26 @@ int main (int argc, char *argv []) ...@@ -285,6 +304,26 @@ int main (int argc, char *argv [])
} }
} }
uint32_t rcvlen = 0;
if (rcvlen_sel == 1) {
rcvlen = strtoul (rcvlen_str, NULL, 10);
bpm_client_err_e err = bpm_set_trigger_rcv_len (bpm_client, service_iface, chan, rcvlen);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:trigger]: bpm_set_trigger_rcv_len failed\n");
goto err_bpm_set;
}
}
uint32_t trnlen = 0;
if (trnlen_sel == 1) {
trnlen = strtoul (trnlen_str, NULL, 10);
bpm_client_err_e err = bpm_set_trigger_transm_len (bpm_client, service_iface, chan, trnlen);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:trigger]: bpm_set_trigger_transm_len failed\n");
goto err_bpm_set;
}
}
uint32_t dir = 0; uint32_t dir = 0;
if (dir_sel == 1) { if (dir_sel == 1) {
dir = strtoul (dir_str, NULL, 10); dir = strtoul (dir_str, NULL, 10);
...@@ -312,6 +351,10 @@ err_bpm_client_new: ...@@ -312,6 +351,10 @@ err_bpm_client_new:
dirpol_str = NULL; dirpol_str = NULL;
free (dir_str); free (dir_str);
dir_str = NULL; dir_str = NULL;
free (trnlen_str);
trnlen_str = NULL;
free (rcvlen_str);
rcvlen_str = NULL;
free (transmsel_str); free (transmsel_str);
transmsel_str = NULL; transmsel_str = NULL;
free (transmsrc_str); free (transmsrc_str);
......
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