srsRAN_4G
srsRAN_4G copied to clipboard
Unsupported CLI options in pssch_ue example
Issue Description
The CLI arguments in the pssch_ue example (C-V2X application note) do not match with the usage note. I discovered this when trying to set the number of subchannels (-n). This holds for -s option as well.
The -n option is listed in the usage printing, but not handled in the parse_args function. I think it has to be either removed from the usage or added to the parse_args function, depending if you want it to be set via CLI.
The fix is fairly straight forward in both ways, but you have to decide for one option first.
Additional information:
In the parse_args function, there are sometimes conversions to int32_t and sometimes uint32_t while the target variable is uint32_t anyways. Is there any reason? If not, casting to the "right" type might be preferred and fixed within this issue.
case 'm':
args->file_start_sf_idx = (uint32_t)strtol(argv[optind], NULL, 10); // args->file_start_sf_idx is a uint32_t (everything ok here)
break;
case 'p':
cell_sl.nof_prb = (int32_t)strtol(argv[optind], NULL, 10); // cell_sl.nof_prb is a uint32_t (type mismatch?)
break;
Setup Details
Basic srsRAN 21.04 with B210 SDR + UHD Driver.
Expected Behavior
./lib/examples/pssch_ue -i <FILE>.dat -n 10
I expected this to decode the file with according number of subchannels.
Actual Behaviour
./lib/examples/pssch_ue: invalid option -- 'n'
Steps to reproduce the problem
Trying to set -n 10 for pssch_ue example.
Additional Information
From pssch_ue example
void usage(prog_args_t* args, char* prog)
{
printf("Usage: %s [agrnmv] -f rx_frequency_hz\n", prog);
.
.
.
// Here it is listed
printf("\t-s size_sub_channel [Default for 50 prbs %d]\n", args->size_sub_channel);
printf("\t-n num_sub_channel [Default for 50 prbs %d]\n", args->num_sub_channel);
//
printf("\t-t Sidelink transmission mode {1,2,3,4} [Default %d]\n", (cell_sl.tm + 1));
printf("\t-r use_standard_lte_rates [Default %i]\n", args->use_standard_lte_rates);
#ifdef ENABLE_GUI
printf("\t-w disable plots [Default enabled]\n");
#endif
printf("\t-v srsran_verbose\n");
}
void parse_args(prog_args_t* args, int argc, char** argv)
{
int opt;
args_default(args);
// Missing n and s in the getopt string part below:
while ((opt = getopt(argc, argv, "acdimgpvwrxfA")) != -1) {
switch (opt) {
case 'a':
args->rf_args = argv[optind];
break;
case 'c':
cell_sl.N_sl_id = (int32_t)strtol(argv[optind], NULL, 10);
break;
case 'd':
args->rf_dev = argv[optind];
break;
case 'i':
args->input_file_name = argv[optind];
break;
case 'm':
args->file_start_sf_idx = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'g':
args->rf_gain = strtof(argv[optind], NULL);
break;
case 'p':
cell_sl.nof_prb = (int32_t)strtol(argv[optind], NULL, 10);
break;
case 'f':
args->rf_freq = strtof(argv[optind], NULL);
break;
case 'A':
args->nof_rx_antennas = (int32_t)strtol(argv[optind], NULL, 10);
break;
case 'v':
srsran_verbose++;
break;
case 'w':
args->disable_plots = true;
break;
case 'r':
args->use_standard_lte_rates = true;
break;
// Possible addition to support -n / -s option:
case 's':
args->size_sub_channel = (uint32_t)strtol(argv[optind], NULL, 10);
break;
case 'n':
args->num_sub_channel = (uint32_t)strtol(argv[optind], NULL, 10);
break;
//
default:
usage(args, argv[0]);
exit(-1);
}
}
if (args->rf_freq < 0 && args->input_file_name == NULL) {
usage(args, argv[0]);
exit(-1);
}
}
Thanks for reporting. We'll check this.