handle config parsing error gracefully and fix op/opc selection issue

This commit is contained in:
Andre Puschmann 2018-06-29 14:53:00 +02:00
parent 8c92f3fddc
commit 3dc5a40caf
2 changed files with 12 additions and 13 deletions

View File

@ -363,8 +363,14 @@ void parse_args(all_args_t *args, int argc, char *argv[]) {
exit(1);
}
bpo::store(bpo::parse_config_file(conf, common), vm);
bpo::notify(vm);
// parse config file and handle errors gracefully
try {
bpo::store(bpo::parse_config_file(conf, common), vm);
bpo::notify(vm);
} catch (const boost::program_options::error& e) {
cerr << e.what() << endl;
exit(1);
}
//Check conflicting OP/OPc options and which is being used
if (vm.count("usim.op") && !vm["usim.op"].defaulted() &&
@ -373,14 +379,8 @@ void parse_args(all_args_t *args, int argc, char *argv[]) {
cout << "Conflicting options OP and OPc. Please configure either one or the other." << endl;
exit(1);
}
else
{
if(vm["usim.op"].defaulted()){
args->usim.using_op = true;
}
else{
args->usim.using_op = false;
}
else {
args->usim.using_op = vm.count("usim.op");
}
// Apply all_level to any unset layers

View File

@ -53,8 +53,7 @@ int usim::init(usim_args_t *args, srslte::log *usim_log_)
usim_log->console("Invalid length for K: %zu should be %d\n", args->k.length(), 32);
}
if(args->using_op)
{
if(args->using_op) {
if(32 == args->op.length()) {
str_to_hex(args->op, op);
compute_opc(k,op,opc);
@ -63,7 +62,7 @@ int usim::init(usim_args_t *args, srslte::log *usim_log_)
usim_log->console("Invalid length for OP: %zu should be %d\n", args->op.length(), 32);
}
}
else{
else {
if(32 == args->opc.length()) {
str_to_hex(args->opc, opc);
} else {