Skip to content

Commit a8683b2

Browse files
falucocodebot
authored andcommitted
cfg: Misc improvements to cfg, eg:fixing flag descriptions, renaming.
Replaced an assertion with a report_error to avoid showing a backtrace on invalid configs.
1 parent dc38f1e commit a8683b2

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

apps/gnb/gnb_appconfig_cli11_schema.cpp

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static void configure_cli11_log_args(CLI::App& app, log_appconfig& log_params)
4242
app.add_option("--sdap_level", log_params.sdap_level, "SDAP log level")->capture_default_str()->check(level_check);
4343
app.add_option("--gtpu_level", log_params.gtpu_level, "GTPU log level")->capture_default_str()->check(level_check);
4444
app.add_option("--fapi_level", log_params.fapi_level, "FAPI log level")->capture_default_str()->check(level_check);
45-
app.add_option("--hex_max_size", log_params.hex_max_size, "Number of bytes to print in hex")
45+
app.add_option("--hex_max_size", log_params.hex_max_size, "Maximum number of bytes to print in hex")
4646
->capture_default_str()
4747
->check(CLI::Range(0, 1024));
4848
app.add_option("--broadcast_enabled",
@@ -51,12 +51,10 @@ static void configure_cli11_log_args(CLI::App& app, log_appconfig& log_params)
5151
->always_capture_default();
5252
app.add_option("--phy_rx_symbols_filename",
5353
log_params.phy_rx_symbols_filename,
54-
"Set to a valid file path to print the received symbols.")
54+
"Set to a valid file path to print the received symbols")
5555
->always_capture_default();
5656

57-
/// Post-parsing callback. This allows us to
58-
/// set the log level to "all" level, if no level
59-
/// is provided.
57+
// Post-parsing callback. This allows us to set the log level to "all" level, if no level is provided.
6058
app.callback([&]() {
6159
if (app.count("--app_level") == 0) {
6260
log_params.app_level = log_params.all_level;
@@ -120,14 +118,14 @@ static void configure_cli11_rf_driver_args(CLI::App& app, rf_driver_appconfig& r
120118
{
121119
app.add_option("--srate", rf_driver_params.srate_MHz, "Sample rate in MHz")->capture_default_str();
122120
app.add_option("--device_driver", rf_driver_params.device_driver, "Device driver name")->capture_default_str();
123-
app.add_option("--device_args", rf_driver_params.device_arguments, "Optional device arguments.")
121+
app.add_option("--device_args", rf_driver_params.device_arguments, "Optional device arguments")
124122
->capture_default_str();
125-
app.add_option("--tx_gain", rf_driver_params.tx_gain_dB, "Transmit gain in decibels.")->capture_default_str();
126-
app.add_option("--rx_gain", rf_driver_params.rx_gain_dB, "Receive gain in decibels.")->capture_default_str();
127-
app.add_option("--lo_offset", rf_driver_params.lo_offset_MHz, "LO frequency offset in MHz.")->capture_default_str();
128-
app.add_option("--clock", rf_driver_params.clock_source, "Clock source.")->capture_default_str();
129-
app.add_option("--sync", rf_driver_params.synch_source, "Time synchronization source.")->capture_default_str();
130-
app.add_option("--otw_format", rf_driver_params.otw_format, "Over-the-wire format.")->capture_default_str();
123+
app.add_option("--tx_gain", rf_driver_params.tx_gain_dB, "Transmit gain in decibels")->capture_default_str();
124+
app.add_option("--rx_gain", rf_driver_params.rx_gain_dB, "Receive gain in decibels")->capture_default_str();
125+
app.add_option("--lo_offset", rf_driver_params.lo_offset_MHz, "LO frequency offset in MHz")->capture_default_str();
126+
app.add_option("--clock", rf_driver_params.clock_source, "Clock source")->capture_default_str();
127+
app.add_option("--sync", rf_driver_params.synch_source, "Time synchronization source")->capture_default_str();
128+
app.add_option("--otw_format", rf_driver_params.otw_format, "Over-the-wire format")->capture_default_str();
131129
app.add_option_function<std::string>(
132130
"--time_alignment_calibration",
133131
[&rf_driver_params](const std::string& value) {
@@ -140,7 +138,7 @@ static void configure_cli11_rf_driver_args(CLI::App& app, rf_driver_appconfig& r
140138
},
141139
"Rx to Tx radio time alignment calibration in samples.\n"
142140
"Positive values reduce the RF transmission delay with respect\n"
143-
"to the RF reception, while negative values increase it.")
141+
"to the RF reception, while negative values increase it")
144142
->check([](const std::string& value) -> std::string {
145143
// Check for valid option "auto".
146144
if (value == "auto") {
@@ -156,17 +154,17 @@ static void configure_cli11_rf_driver_args(CLI::App& app, rf_driver_appconfig& r
156154

157155
static void configure_cli11_expert_phy_args(CLI::App& app, expert_phy_appconfig& expert_phy_params)
158156
{
159-
app.add_option("--nof_ul_threads", expert_phy_params.nof_ul_threads, "Number of threads to process uplink.")
157+
app.add_option("--nof_ul_threads", expert_phy_params.nof_ul_threads, "Number of threads to process uplink")
160158
->capture_default_str()
161159
->check(CLI::Number);
162160
app.add_option("--pusch_dec_max_iterations",
163161
expert_phy_params.pusch_decoder_max_iterations,
164-
"Maximum number of PUSCH LDPC decoder iterations.")
162+
"Maximum number of PUSCH LDPC decoder iterations")
165163
->capture_default_str()
166164
->check(CLI::Number);
167165
app.add_option("--pusch_dec_enable_early_stop",
168166
expert_phy_params.pusch_decoder_early_stop,
169-
"Enables PUSCH LDPC decoder early stop.")
167+
"Enables PUSCH LDPC decoder early stop")
170168
->capture_default_str();
171169
}
172170

@@ -212,7 +210,9 @@ static void configure_cli11_prach_args(CLI::App& app, prach_appconfig& prach_par
212210

213211
static void configure_cli11_amplitude_control_args(CLI::App& app, amplitude_control_appconfig& amplitude_params)
214212
{
215-
app.add_option("--tx_gain_backoff", amplitude_params.gain_backoff_dB, "Gain back-off to accommodate the signal PAPR")
213+
app.add_option("--tx_gain_backoff",
214+
amplitude_params.gain_backoff_dB,
215+
"Gain back-off to accommodate the signal PAPR in decibels")
216216
->capture_default_str();
217217
app.add_option("--enable_clipping", amplitude_params.enable_clipping, "Signal clipping")->capture_default_str();
218218
app.add_option("--ceiling", amplitude_params.power_ceiling_dBFS, "Clipping ceiling referenced to full scale")
@@ -222,7 +222,7 @@ static void configure_cli11_amplitude_control_args(CLI::App& app, amplitude_cont
222222
static void configure_cli11_common_cell_args(CLI::App& app, base_cell_appconfig& cell_params)
223223
{
224224
app.add_option("--pci", cell_params.pci, "PCI")->capture_default_str()->check(CLI::Range(0, 1007));
225-
app.add_option("--dl_arfcn", cell_params.dl_arfcn, "Donwlink ARFCN")->capture_default_str();
225+
app.add_option("--dl_arfcn", cell_params.dl_arfcn, "Downlink ARFCN")->capture_default_str();
226226
add_auto_enum_option(app, "--band", cell_params.band, "NR band");
227227
app.add_option("--common_scs", cell_params.common_scs, "Cell common subcarrier spacing")
228228
->transform([](const std::string& value) {
@@ -364,7 +364,7 @@ void srsran::configure_cli11_with_gnb_appconfig_schema(CLI::App& app, gnb_appcon
364364
configure_cli11_rf_driver_args(*rf_driver_subcmd, gnb_cfg.rf_driver_cfg);
365365

366366
// Common cell parameters.
367-
CLI::App* common_cell_subcmd = app.add_subcommand("common_cell", "Common cell parameters")->configurable();
367+
CLI::App* common_cell_subcmd = app.add_subcommand("cell_cfg", "Cell configuration")->configurable();
368368
configure_cli11_common_cell_args(*common_cell_subcmd, gnb_cfg.common_cell_cfg);
369369
// Configure the cells to use the common cell parameters once it has been parsed and before parsing the cells.
370370
common_cell_subcmd->parse_complete_callback([&gnb_cfg]() {
@@ -402,7 +402,7 @@ void srsran::configure_cli11_with_gnb_appconfig_schema(CLI::App& app, gnb_appcon
402402
// Prepare the radio bearers
403403
gnb_cfg.qos_cfg.resize(values.size());
404404

405-
//// Format every QoS setting.
405+
// Format every QoS setting.
406406
for (unsigned i = 0, e = values.size(); i != e; ++i) {
407407
CLI::App subapp("QoS parameters");
408408
subapp.config_formatter(create_yaml_config_parser());
@@ -415,7 +415,6 @@ void srsran::configure_cli11_with_gnb_appconfig_schema(CLI::App& app, gnb_appcon
415415
app.add_option_function<std::vector<std::string>>("--qos", qos_lambda, "qos");
416416

417417
// Expert PHY section.
418-
CLI::App* expert_phy_subcmd =
419-
app.add_subcommand("expert_phy", "Expert physical layer configuration.")->configurable();
418+
CLI::App* expert_phy_subcmd = app.add_subcommand("expert_phy", "Expert physical layer configuration")->configurable();
420419
configure_cli11_expert_phy_args(*expert_phy_subcmd, gnb_cfg.expert_phy_cfg);
421420
}

apps/gnb/gnb_appconfig_translators.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,10 @@ radio_configuration::radio srsran::generate_radio_config(const gnb_appconfig&
328328

329329
// Add the tx ports.
330330
if (config.rf_driver_cfg.device_driver == "zmq") {
331-
srsran_assert(sector_id * nof_ports + port_id < zmq_tx_addr.size(),
332-
"Transmission channel arguments out of bounds");
331+
if (sector_id * nof_ports + port_id >= zmq_tx_addr.size()) {
332+
report_error("ZMQ transmission channel arguments out of bounds");
333+
}
334+
333335
tx_ch_config.args = zmq_tx_addr[sector_id * nof_ports + port_id];
334336
}
335337
tx_stream_config.channels.emplace_back(tx_ch_config);
@@ -344,8 +346,10 @@ radio_configuration::radio srsran::generate_radio_config(const gnb_appconfig&
344346
rx_ch_config.gain_dB = config.rf_driver_cfg.rx_gain_dB;
345347

346348
if (config.rf_driver_cfg.device_driver == "zmq") {
347-
srsran_assert(sector_id * nof_ports + port_id < zmq_rx_addr.size(),
348-
"Reception channel arguments out of bounds");
349+
if (sector_id * nof_ports + port_id >= zmq_rx_addr.size()) {
350+
report_error("ZMQ reception channel arguments out of bounds");
351+
}
352+
349353
rx_ch_config.args = zmq_rx_addr[sector_id * nof_ports + port_id];
350354
}
351355
rx_stream_config.channels.emplace_back(rx_ch_config);

0 commit comments

Comments
 (0)