From 4455b375489c0a0e8b040b4e9138869d9c013182 Mon Sep 17 00:00:00 2001 From: Romain Beurdouche Date: Thu, 2 May 2024 11:10:56 +0200 Subject: [PATCH 1/5] fix(nr_ulsim): fix cmdline configmodule for nr_ulsim --- openair1/SIMULATION/NR_PHY/ulsim.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/openair1/SIMULATION/NR_PHY/ulsim.c b/openair1/SIMULATION/NR_PHY/ulsim.c index 90f23c695c..e363b0c47d 100644 --- a/openair1/SIMULATION/NR_PHY/ulsim.c +++ b/openair1/SIMULATION/NR_PHY/ulsim.c @@ -223,7 +223,13 @@ int main(int argc, char *argv[]) /* initialize the sin-cos table */ InitSinLUT(); - while ((c = getopt(argc, argv, "a:b:c:d:ef:g:h:i:k:m:n:op:q:r:s:t:u:v:w:y:z:C:F:G:H:I:M:N:PR:S:T:U:L:ZW:E:X:")) != -1) { + while ((c = getopt(argc, argv, "--:a:b:c:d:ef:g:h:i:k:m:n:op:q:r:s:t:u:v:w:y:z:C:F:G:H:I:M:N:PR:S:T:U:L:ZW:E:X:")) != -1) { + + /* ignore long options starting with '--' and their arguments that are handled by configmodule */ + /* with this opstring getopt returns 1 for non-option arguments, refer to 'man 3 getopt' */ + if (c == 1 || c == '-') + continue; + printf("handling optarg %c\n",c); switch (c) { From 4e8f58b498afc709db000efec9e73c51e24cd086 Mon Sep 17 00:00:00 2001 From: Romain Beurdouche Date: Thu, 2 May 2024 11:19:20 +0200 Subject: [PATCH 2/5] fix(nr_dlsim): fix cmdline configmodule for nr_dlsim --- openair1/SIMULATION/NR_PHY/dlsim.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openair1/SIMULATION/NR_PHY/dlsim.c b/openair1/SIMULATION/NR_PHY/dlsim.c index 74d4568b70..ac37c03336 100644 --- a/openair1/SIMULATION/NR_PHY/dlsim.c +++ b/openair1/SIMULATION/NR_PHY/dlsim.c @@ -336,7 +336,14 @@ int main(int argc, char **argv) FILE *scg_fd=NULL; - while ((c = getopt(argc, argv, "f:hA:p:f:g:i:n:s:S:t:v:x:y:z:o:M:N:F:GR:d:PI:L:a:b:e:m:w:T:U:q:X:Y:Z:c")) != -1) { + while ((c = getopt(argc, argv, "--:f:hA:p:f:g:i:n:s:S:t:v:x:y:z:o:M:N:F:GR:d:PI:L:a:b:e:m:w:T:U:q:X:Y:Z:c")) != -1) { + + /* ignore long options starting with '--' and their arguments that are handled by configmodule */ + /* with this opstring getopt returns 1 for non-option arguments, refer to 'man 3 getopt' */ + if (c == 1 || c == '-') + continue; + + printf("handling optarg %c\n",c); switch (c) { case 'f': scg_fd = fopen(optarg,"r"); From 08dbc5bf0838218e7e5a433041b7868de682d1dc Mon Sep 17 00:00:00 2001 From: Romain Beurdouche Date: Thu, 2 May 2024 17:39:33 +0200 Subject: [PATCH 3/5] fix(phy simulators): fix cmdline configmodule for NR_PHY simulators --- openair1/SIMULATION/NR_PHY/dlschsim.c | 9 ++++++++- openair1/SIMULATION/NR_PHY/pbchsim.c | 9 ++++++++- openair1/SIMULATION/NR_PHY/prachsim.c | 9 ++++++++- openair1/SIMULATION/NR_PHY/psbchsim.c | 8 +++++++- openair1/SIMULATION/NR_PHY/pucchsim.c | 9 ++++++++- openair1/SIMULATION/NR_PHY/ulschsim.c | 11 +++++++++-- 6 files changed, 48 insertions(+), 7 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/dlschsim.c b/openair1/SIMULATION/NR_PHY/dlschsim.c index 0e9968d02b..7466da841c 100644 --- a/openair1/SIMULATION/NR_PHY/dlschsim.c +++ b/openair1/SIMULATION/NR_PHY/dlschsim.c @@ -146,7 +146,14 @@ int main(int argc, char **argv) // logInit(); randominit(0); - while ((c = getopt(argc, argv, "df:hpVg:i:j:n:l:m:r:s:S:y:z:M:N:F:R:P:L:X:")) != -1) { + while ((c = getopt(argc, argv, "--:df:hpVg:i:j:n:l:m:r:s:S:y:z:M:N:F:R:P:L:X:")) != -1) { + + /* ignore long options starting with '--' and their arguments that are handled by configmodule */ + /* with this opstring getopt returns 1 for non-option arguments, refer to 'man 3 getopt' */ + if (c == 1 || c == '-') + continue; + + printf("handling optarg %c\n",c); switch (c) { /*case 'f': write_output_file = 1; diff --git a/openair1/SIMULATION/NR_PHY/pbchsim.c b/openair1/SIMULATION/NR_PHY/pbchsim.c index 408fe64d28..ae452b66ff 100644 --- a/openair1/SIMULATION/NR_PHY/pbchsim.c +++ b/openair1/SIMULATION/NR_PHY/pbchsim.c @@ -243,7 +243,14 @@ int main(int argc, char **argv) exit_fun("[NR_PBCHSIM] Error, configuration module init failed\n"); } - while ((c = getopt (argc, argv, "F:g:hIL:m:M:n:N:o:O:P:r:R:s:S:x:y:z:")) != -1) { + while ((c = getopt (argc, argv, "--:F:g:hIL:m:M:n:N:o:O:P:r:R:s:S:x:y:z:")) != -1) { + + /* ignore long options starting with '--' and their arguments that are handled by configmodule */ + /* with this opstring getopt returns 1 for non-option arguments, refer to 'man 3 getopt' */ + if (c == 1 || c == '-') + continue; + + printf("handling optarg %c\n",c); switch (c) { /*case 'f': write_output_file=1; diff --git a/openair1/SIMULATION/NR_PHY/prachsim.c b/openair1/SIMULATION/NR_PHY/prachsim.c index 9586cf2d64..ef05cd4940 100644 --- a/openair1/SIMULATION/NR_PHY/prachsim.c +++ b/openair1/SIMULATION/NR_PHY/prachsim.c @@ -164,7 +164,14 @@ int main(int argc, char **argv){ randominit(0); - while ((c = getopt (argc, argv, "hHaA:Cc:l:r:p:g:m:n:s:S:t:x:y:v:V:z:N:F:d:Z:L:R:E")) != -1) { + while ((c = getopt (argc, argv, "--:hHaA:Cc:l:r:p:g:m:n:s:S:t:x:y:v:V:z:N:F:d:Z:L:R:E")) != -1) { + + /* ignore long options starting with '--' and their arguments that are handled by configmodule */ + /* with this opstring getopt returns 1 for non-option arguments, refer to 'man 3 getopt' */ + if (c == 1 || c == '-') + continue; + + printf("handling optarg %c\n",c); switch (c) { case 'a': printf("Running AWGN simulation\n"); diff --git a/openair1/SIMULATION/NR_PHY/psbchsim.c b/openair1/SIMULATION/NR_PHY/psbchsim.c index b30405bef9..fd96f233ca 100644 --- a/openair1/SIMULATION/NR_PHY/psbchsim.c +++ b/openair1/SIMULATION/NR_PHY/psbchsim.c @@ -313,7 +313,13 @@ int main(int argc, char **argv) randominit(0); - while ((c = getopt(argc, argv, "c:hn:o:s:FIL:N:R:S:T:")) != -1) { + while ((c = getopt(argc, argv, "--:c:hn:o:s:FIL:N:R:S:T:")) != -1) { + + /* ignore long options starting with '--' and their arguments that are handled by configmodule */ + /* with this opstring getopt returns 1 for non-option arguments, refer to 'man 3 getopt' */ + if (c == 1 || c == '-') + continue; + printf("SIDELINK PSBCH SIM: handling optarg %c\n", c); switch (c) { case 'c': diff --git a/openair1/SIMULATION/NR_PHY/pucchsim.c b/openair1/SIMULATION/NR_PHY/pucchsim.c index 1afba2ba85..f9c25a48c8 100644 --- a/openair1/SIMULATION/NR_PHY/pucchsim.c +++ b/openair1/SIMULATION/NR_PHY/pucchsim.c @@ -155,7 +155,14 @@ int main(int argc, char **argv) randominit(0); logInit(); - while ((c = getopt (argc, argv, "f:hA:f:g:i:I:P:B:b:t:T:m:n:r:o:s:S:x:y:z:N:F:GR:IL:q:cd:")) != -1) { + while ((c = getopt (argc, argv, "--:f:hA:f:g:i:I:P:B:b:t:T:m:n:r:o:s:S:x:y:z:N:F:GR:IL:q:cd:")) != -1) { + + /* ignore long options starting with '--' and their arguments that are handled by configmodule */ + /* with this opstring getopt returns 1 for non-option arguments, refer to 'man 3 getopt' */ + if (c == 1 || c == '-') + continue; + + printf("handling optarg %c\n",c); switch (c) { case 'f': //write_output_file=1; diff --git a/openair1/SIMULATION/NR_PHY/ulschsim.c b/openair1/SIMULATION/NR_PHY/ulschsim.c index b41896da5e..1da4da5b24 100644 --- a/openair1/SIMULATION/NR_PHY/ulschsim.c +++ b/openair1/SIMULATION/NR_PHY/ulschsim.c @@ -165,8 +165,15 @@ int main(int argc, char **argv) //logInit(); randominit(0); - //while ((c = getopt(argc, argv, "df:hpg:i:j:n:l:m:r:s:S:y:z:M:N:F:R:P:")) != -1) { - while ((c = getopt(argc, argv, "hg:n:s:S:py:z:M:N:R:F:m:l:q:r:W:")) != -1) { + //while ((c = getopt(argc, argv, "--:df:hpg:i:j:n:l:m:r:s:S:y:z:M:N:F:R:P:")) != -1) { + while ((c = getopt(argc, argv, "--:hg:n:s:S:py:z:M:N:R:F:m:l:q:r:W:")) != -1) { + + /* ignore long options starting with '--' and their arguments that are handled by configmodule */ + /* with this opstring getopt returns 1 for non-option arguments, refer to 'man 3 getopt' */ + if (c == 1 || c == '-') + continue; + + printf("handling optarg %c\n",c); switch (c) { /*case 'f': write_output_file = 1; From 8b889d908c7d48fff51b9545a82f2eb06f51755d Mon Sep 17 00:00:00 2001 From: Romain Beurdouche Date: Tue, 7 May 2024 17:12:11 +0200 Subject: [PATCH 4/5] fix(phy simulators): fix cmdline configmodule for LTE_PHY ulsim and dlsim --- openair1/SIMULATION/LTE_PHY/dlsim.c | 14 +++++++++++--- openair1/SIMULATION/LTE_PHY/ulsim.c | 14 +++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index e8b08a1921..2f112ddc99 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -662,7 +662,15 @@ int main(int argc, char **argv) { int option_index; int res; - while ((res=getopt_long_only(argc, argv, "", long_options, &option_index)) == 0) { + /* disable error messages from getopt_long_only */ + opterr = 0; + while ((res=getopt_long_only(argc, argv, "-", long_options, &option_index)) >= 0) { + + /* ignore configmodule options and their arguments*/ + /* with these opstring and long_options getopt returns 1 for non-option arguments and '?' for unrecognized long options, refer to 'man 3 getopt' */ + if (res == 1 || res == '?') + continue; + if (options[option_index].voidptr != NULL ) { if (long_options[option_index].has_arg==no_argument) *(bool *)options[option_index].iptr=1; @@ -877,8 +885,8 @@ int main(int argc, char **argv) { if (transmission_mode>1) pa=dBm3; printf("dlsim: tmode %d, pa %d\n",transmission_mode,pa); - AssertFatal((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) != NULL, - "Cannot load configuration module, exiting\n"); + uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY); + AssertFatal(uniqCfg != NULL, "Cannot load configuration module, exiting\n"); logInit(); set_glog_onlinelog(true); // enable these lines if you need debug info diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index 19c9ded376..7898365e66 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -395,8 +395,8 @@ int main(int argc, char **argv) { cpuf = cpu_freq_GHz; set_parallel_conf("PARALLEL_SINGLE_THREAD"); printf("Detected cpu_freq %f GHz\n",cpu_freq_GHz); - AssertFatal((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) != NULL, - "Cannot load configuration module, exiting\n"); + uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY); + AssertFatal(uniqCfg != NULL, "Cannot load configuration module, exiting\n"); logInit(); set_glog(OAILOG_INFO); // enable these lines if you need debug info @@ -447,7 +447,15 @@ int main(int argc, char **argv) { int option_index; int res; - while ((res=getopt_long_only(argc, argv, "", long_options, &option_index)) == 0) { + /* disable error messages from getopt_long_only */ + opterr = 0; + while ((res=getopt_long_only(argc, argv, "-", long_options, &option_index)) >= 0) { + + /* ignore configmodule options and their arguments*/ + /* with these opstring and long_options getopt returns 1 for non-option arguments and '?' for unrecognized long options, refer to 'man 3 getopt' */ + if (res == 1 || res == '?') + continue; + if (options[option_index].voidptr != NULL ) { if (long_options[option_index].has_arg==no_argument) *(bool *)options[option_index].iptr=1; From b51a144d7dd0ee3e4677bcc089ef492904187b3b Mon Sep 17 00:00:00 2001 From: Romain Beurdouche Date: Mon, 13 May 2024 16:35:44 +0200 Subject: [PATCH 5/5] fix(phy simulators): fix cmdline configmodule for CODING phy simulators --- openair1/PHY/CODING/TESTBENCH/ldpctest.c | 18 ++++++++++++++++-- openair1/PHY/CODING/TESTBENCH/polartest.c | 15 ++++++++++++++- openair1/PHY/CODING/TESTBENCH/smallblocktest.c | 16 +++++++++++++++- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/CODING/TESTBENCH/ldpctest.c b/openair1/PHY/CODING/TESTBENCH/ldpctest.c index 7a3d299139..43a84e4b8f 100644 --- a/openair1/PHY/CODING/TESTBENCH/ldpctest.c +++ b/openair1/PHY/CODING/TESTBENCH/ldpctest.c @@ -26,6 +26,7 @@ #include #include "assertions.h" #include "SIMULATION/TOOLS/sim.h" +#include "common/config/config_userapi.h" #include "common/utils/load_module_shlib.h" #include "PHY/CODING/nrLDPC_extern.h" //#include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h" @@ -402,7 +403,7 @@ int main(int argc, char *argv[]) { short block_length=8448; // decoder supports length: 1201 -> 1280, 2401 -> 2560 // default to check output inside ldpc, the NR version checks the outer CRC defined by 3GPP - char *ldpc_version = ""; + char *ldpc_version = NULL; /* version of the ldpc decoder library to use (XXX suffix to use when loading libldpc_XXX.so */ short max_iterations=5; int n_segments=1; @@ -424,7 +425,19 @@ int main(int argc, char *argv[]) short BG = 0, Zc; - while ((c = getopt (argc, argv, "q:r:s:S:l:G:n:d:i:t:u:hv:")) != -1) + if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == 0) { + exit_fun("[LDPCTEST] Error, configuration module init failed\n"); + } + logInit(); + + while ((c = getopt (argc, argv, "--:q:r:s:S:l:G:n:d:i:t:u:hv:")) != -1) { + + /* ignore long options starting with '--' and their arguments that are handled by configmodule */ + /* with this opstring getopt returns 1 for non-option arguments, refer to 'man 3 getopt' */ + if (c == 1 || c == '-') + continue; + + printf("handling optarg %c\n",c); switch (c) { case 'q': qbits = atoi(optarg); @@ -494,6 +507,7 @@ int main(int argc, char *argv[]) exit(1); break; } + } //printf("the decoder supports BG2, Kb=10, Z=128 & 256\n"); //printf(" range of blocklength: 1201 -> 1280, 2401 -> 2560\n"); printf("block length %d: \n", block_length); diff --git a/openair1/PHY/CODING/TESTBENCH/polartest.c b/openair1/PHY/CODING/TESTBENCH/polartest.c index 100df821d2..78b44599fb 100644 --- a/openair1/PHY/CODING/TESTBENCH/polartest.c +++ b/openair1/PHY/CODING/TESTBENCH/polartest.c @@ -11,6 +11,7 @@ #include "PHY/CODING/nrPolar_tools/nr_polar_uci_defs.h" #include "PHY/CODING/coding_defs.h" #include "SIMULATION/TOOLS/sim.h" +#include "common/config/config_userapi.h" //#include "common/utils/LOG/log.h" #include "coding_unitary_defs.h" //#define DEBUG_DCI_POLAR_PARAMS @@ -32,7 +33,19 @@ int main(int argc, char *argv[]) uint8_t aggregation_level = 8, decoderListSize = 8, logFlag = 0; uint16_t rnti=0; - while ((arguments = getopt (argc, argv, "s:d:f:m:i:l:a:p:hqgFL:k:")) != -1) { + if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == 0) { + exit_fun("[POLARTEST] Error, configuration module init failed\n"); + } + logInit(); + + while ((arguments = getopt (argc, argv, "--:s:d:f:m:i:l:a:p:hqgFL:k:")) != -1) { + + /* ignore long options starting with '--' and their arguments that are handled by configmodule */ + /* with this opstring getopt returns 1 for non-option arguments, refer to 'man 3 getopt' */ + if (arguments == 1 || arguments == '-') + continue; + + printf("handling optarg %c\n",arguments); switch (arguments) { case 's': SNRstart = atof(optarg); diff --git a/openair1/PHY/CODING/TESTBENCH/smallblocktest.c b/openair1/PHY/CODING/TESTBENCH/smallblocktest.c index 36e71b2a32..d6306495a7 100644 --- a/openair1/PHY/CODING/TESTBENCH/smallblocktest.c +++ b/openair1/PHY/CODING/TESTBENCH/smallblocktest.c @@ -1,4 +1,5 @@ #include +#include "common/config/config_userapi.h" #include "SIMULATION/TOOLS/sim.h" #include "PHY/CODING/nrSmallBlock/nr_small_block_defs.h" #include "coding_unitary_defs.h" @@ -26,7 +27,19 @@ int main(int argc, char *argv[]) int8_t channelOutput_int8[NR_SMALL_BLOCK_CODED_BITS]; unsigned char qbits = 8; - while ((arguments = getopt(argc, argv, "s:d:f:l:i:mhg")) != -1) + if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == 0) { + exit_fun("[SMALLBLOCKTEST] Error, configuration module init failed\n"); + } + logInit(); + + while ((arguments = getopt(argc, argv, "--:s:d:f:l:i:mhg")) != -1) { + + /* ignore long options starting with '--' and their arguments that are handled by configmodule */ + /* with this opstring getopt returns 1 for non-option arguments, refer to 'man 3 getopt' */ + if (arguments == 1 || arguments == '-') + continue; + + printf("handling optarg %c\n",arguments); switch (arguments) { case 's': SNRstart = atof(optarg); @@ -69,6 +82,7 @@ int main(int argc, char *argv[]) perror("[smallblocktest.c] Problem at argument parsing with getopt"); exit(-1); } + } uint16_t mask = 0x07ff >> (11 - messageLength); for (SNR = SNRstart; SNR <= SNRstop; SNR += SNRinc) {