Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
spbro
OpenXG-RAN
Commits
1fee616d
Commit
1fee616d
authored
Apr 01, 2022
by
frtabu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config module enhancement,step 2
parent
1eb79272
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
17 deletions
+82
-17
common/config/config_load_configmodule.c
common/config/config_load_configmodule.c
+10
-2
common/config/config_load_configmodule.h
common/config/config_load_configmodule.h
+15
-0
common/config/libconfig/config_libconfig.c
common/config/libconfig/config_libconfig.c
+55
-12
common/config/libconfig/config_libconfig.h
common/config/libconfig/config_libconfig.h
+0
-2
executables/nr-ru.c
executables/nr-ru.c
+2
-1
No files found.
common/config/config_load_configmodule.c
View file @
1fee616d
...
...
@@ -316,7 +316,9 @@ configmodule_interface_t *load_configmodule(int argc,
printf
(
"%s "
,
cfgptr
->
cfgP
[
i
]);
}
if
(
cfgptr
->
rtflags
&
CONFIG_PRINTPARAMS
)
{
cfgptr
->
status
=
malloc
(
sizeof
(
configmodule_status_t
));
}
if
(
strstr
(
cfgparam
,
CONFIG_CMDLINEONLY
)
==
NULL
)
{
i
=
load_config_sharedlib
(
cfgptr
);
...
...
@@ -357,6 +359,12 @@ configmodule_interface_t *load_configmodule(int argc,
/* free memory allocated when reading parameters */
/* config module could be initialized again after this call */
void
end_configmodule
(
void
)
{
if
(
cfgptr
->
status
&&
(
cfgptr
->
rtflags
&
CONFIG_SAVERUNCFG
))
{
printf_params
(
"[CONFIG] Runtime params creation status: %i null values, %i errors, %i successfull
\n
"
,
cfgptr
->
status
->
num_err_nullvalue
,
cfgptr
->
status
->
num_err_write
,
cfgptr
->
status
->
num_write
);
}
if
(
cfgptr
!=
NULL
)
{
if
(
cfgptr
->
end
!=
NULL
)
{
printf
(
"[CONFIG] calling config module end function...
\n
"
);
...
...
@@ -382,7 +390,7 @@ void end_configmodule(void) {
void
free_configmodule
(
void
)
{
if
(
cfgptr
!=
NULL
)
{
end_configmodule
();
if
(
cfgptr
->
status
!=
NULL
)
free
(
cfgptr
->
status
);
if
(
cfgptr
->
cfgmode
!=
NULL
)
free
(
cfgptr
->
cfgmode
);
printf
(
"[CONFIG] free %i config parameter pointers
\n
"
,
cfgptr
->
num_cfgP
);
...
...
common/config/config_load_configmodule.h
View file @
1fee616d
...
...
@@ -64,6 +64,20 @@ typedef int(*configmodule_getfunc_t)(paramdef_t *,int numparams, char *prefix);
typedef
int
(
*
configmodule_getlistfunc_t
)(
paramlist_def_t
*
,
paramdef_t
*
,
int
numparams
,
char
*
prefix
);
typedef
int
(
*
configmodule_setfunc_t
)(
paramdef_t
*
cfgoptions
,
int
numoptions
,
char
*
prefix
);
typedef
void
(
*
configmodule_endfunc_t
)(
void
);
typedef
struct
configmodule_status
{
int
num_paramgroups
;
char
**
paramgroups_names
;
int
num_err_nullvalue
;
union
{
int
num_err_read
;
int
num_err_write
;
};
union
{
int
num_read
;
int
num_write
;
}
;
}
configmodule_status_t
;
typedef
struct
configmodule_interface
{
int
argc
;
char
**
argv
;
...
...
@@ -81,6 +95,7 @@ typedef struct configmodule_interface {
char
*
ptrs
[
CONFIG_MAX_ALLOCATEDPTRS
];
bool
ptrsAllocated
[
CONFIG_MAX_ALLOCATEDPTRS
];
char
*
tmpdir
;
configmodule_status_t
*
status
;
// allocated in debug mode only
}
configmodule_interface_t
;
#ifdef CONFIG_LOADCONFIG_MAIN
...
...
common/config/libconfig/config_libconfig.c
View file @
1fee616d
...
...
@@ -88,7 +88,7 @@ int read_intarray(paramdef_t *cfgoptions,config_setting_t *setting, char *cfgpat
return
cfgoptions
->
numelt
;
}
int
config_libconfig_setparams
(
paramdef_t
*
cfgoptions
,
int
numoptions
,
config_setting_t
*
asetting
)
{
int
config_libconfig_setparams
(
paramdef_t
*
cfgoptions
,
int
numoptions
,
config_setting_t
*
asetting
,
char
*
prefix
)
{
int
status
;
int
errors
=
0
;
int
notused
=
0
;
...
...
@@ -97,6 +97,14 @@ int config_libconfig_setparams(paramdef_t *cfgoptions, int numoptions, config_se
for
(
int
i
=
0
;
i
<
numoptions
;
i
++
)
{
status
=
CONFIG_FALSE
;
config_setting_t
*
psetting
;
char
*
spath
=
malloc
(((
prefix
==
NULL
)
?
0
:
strlen
(
prefix
))
+
strlen
(
cfgoptions
[
i
].
optname
)
+
10
);
sprintf
(
spath
,
"%s.%s"
,
prefix
,
cfgoptions
[
i
].
optname
);
psetting
=
config_lookup
(
&
(
libconfig_privdata
.
runtcfg
),
spath
);
free
(
spath
);
if
(
psetting
!=
NULL
)
{
printf_params
(
"[LIBCONFIG] setting %s.%s already created
\n
"
,(
prefix
==
NULL
)
?
""
:
prefix
,
cfgoptions
[
i
].
optname
);
continue
;
}
switch
(
cfgoptions
[
i
].
type
)
{
case
TYPE_STRING
:
psetting
=
config_setting_add
(
asetting
,
cfgoptions
[
i
].
optname
,
CONFIG_TYPE_STRING
);
...
...
@@ -116,6 +124,16 @@ int config_libconfig_setparams(paramdef_t *cfgoptions, int numoptions, config_se
}
break
;
case
TYPE_STRINGLIST
:
psetting
=
config_setting_add
(
asetting
,
cfgoptions
[
i
].
optname
,
CONFIG_TYPE_LIST
);
if
(
psetting
!=
NULL
)
for
(
int
j
=
0
;
j
<
cfgoptions
[
i
].
numelt
;
j
++
)
{
config_setting_t
*
elemsetting
=
config_setting_set_string_elem
(
psetting
,
-
1
,
cfgoptions
[
i
].
strptr
[
j
]
);
if
(
elemsetting
==
NULL
)
{
fprintf
(
stderr
,
"[LIBCONFIG] Error: Creating list %s element %i value %s
\n
"
,
cfgoptions
[
i
].
optname
,
j
,
cfgoptions
[
i
].
strptr
[
j
]);
break
;
}
}
break
;
case
TYPE_UINT8
:
...
...
@@ -139,7 +157,16 @@ int config_libconfig_setparams(paramdef_t *cfgoptions, int numoptions, config_se
case
TYPE_UINTARRAY
:
case
TYPE_INTARRAY
:
psetting
=
config_setting_add
(
asetting
,
cfgoptions
[
i
].
optname
,
CONFIG_TYPE_ARRAY
);
if
(
psetting
!=
NULL
)
for
(
int
j
=
0
;
j
<
cfgoptions
[
i
].
numelt
;
j
++
)
{
config_setting_t
*
elemsetting
=
config_setting_set_int_elem
(
psetting
,
-
1
,(
int
)(
cfgoptions
[
i
].
iptr
[
j
])
);
if
(
elemsetting
==
NULL
)
{
fprintf
(
stderr
,
"[LIBCONFIG] Error: Creating array %s, at index %i value %i
\n
"
,
cfgoptions
[
i
].
optname
,
j
,(
int
)(
cfgoptions
[
i
].
iptr
[
j
]));
break
;
}
}
break
;
break
;
case
TYPE_DOUBLE
:
...
...
@@ -168,10 +195,15 @@ int config_libconfig_setparams(paramdef_t *cfgoptions, int numoptions, config_se
printf_params
(
"[LIBCONFIG], %i settings with NULL value pointer
\n
"
,
notused
);
if
(
errors
==
0
)
{
printf_params
(
"[LIBCONFIG], %i settings set successfully "
,
numoptions
);
printf_params
(
"[LIBCONFIG], %i settings set successfully
\n
"
,
numoptions
);
}
else
{
fprintf
(
stderr
,
"[LIBCONFIG] ...%i/%i settings creation errors
\n
"
,
errors
,
numoptions
);
}
if
(
cfgptr
->
status
)
{
cfgptr
->
status
->
num_err_nullvalue
+=
notused
;
cfgptr
->
status
->
num_err_write
+=
errors
;
cfgptr
->
status
->
num_write
+=
numoptions
;
}
return
errors
;
}
...
...
@@ -185,35 +217,45 @@ int config_libconfig_set(paramdef_t *cfgoptions, int numoptions, char *prefix )
prefixbck
=
strdup
(
prefix
);
prefix_elem1
=
strtok_r
(
prefixbck
,
"."
,
&
tokctx1
);
}
int
n1
=
0
;
printf_params
(
"[LIBCONFIG], processing prefix %s
\n
"
,(
prefix
==
NULL
)
?
"NULL"
:
prefix
);
/* parse the prefix , possibly creating groups, lists and list elements */
while
(
prefix_elem1
!=
NULL
)
{
n1
+=
strlen
(
prefix_elem1
)
+
1
;
char
*
prefix_elem2
=
(
n1
<
strlen
(
prefix
)
)
?
prefix_elem1
+
n1
:
""
;
int
n1
=
strlen
(
prefix_elem1
);
char
*
prefix_elem2
=
prefix_elem1
+
n1
+
1
;
printf_params
(
"[LIBCONFIG], processing elem1 %s elem2 %s
\n
"
,
prefix_elem1
,
prefix_elem2
);
/* prefix (the path to the parameter name) may contain groups and elements from a list, which are specified with [] */
if
(
prefix_elem2
[
0
]
!=
'['
)
{
// not a list
config_setting_t
*
tmpset
=
config_setting_lookup
(
asetting
,
prefix_elem1
);
if
(
tmpset
==
NULL
)
asetting
=
config_setting_add
(
asetting
,
prefix_elem1
,
CONFIG_TYPE_GROUP
);
else
asetting
=
tmpset
;
printf_params
(
"[LIBCONFIG], creating or looking for group %s: %s
\n
"
,
prefix_elem1
,(
asetting
==
NULL
)
?
"NOK"
:
"OK"
);
}
else
{
// a list
listidx
=
(
int
)
strtol
(
prefix_elem2
,
NULL
,
10
);
listidx
=
(
int
)
strtol
(
prefix_elem2
+
1
,
NULL
,
10
);
if
(
errno
==
EINVAL
||
errno
==
ERANGE
)
{
printf_params
(
"[LIBCONFIG], Error %s looking for list index in %s
\n
"
,
strerror
(
errno
),
prefix_elem2
);
break
;
}
config_setting_t
*
tmpset
=
config_setting_lookup
(
asetting
,
prefix_elem1
);
if
(
tmpset
==
NULL
)
asetting
=
config_setting_add
(
asetting
,
prefix_elem1
,
CONFIG_TYPE_LIST
);
else
asetting
=
tmpset
;
asetting
=
tmpset
;
printf_params
(
"[LIBCONFIG], creating or looking for list %s: %s
\n
"
,
prefix_elem1
,(
asetting
==
NULL
)
?
"NOK"
:
"OK"
);
if
(
asetting
!=
NULL
)
{
tmpset
=
config_setting_get_elem
(
asetting
,
listidx
);
if
(
tmpset
==
NULL
)
asetting
=
config_setting_add
(
asetting
,
NULL
,
CONFIG_TYPE_GROUP
);
else
asetting
=
tmpset
;
printf_params
(
"[LIBCONFIG], creating or looking for list element %i: %s
\n
"
,
listidx
,(
asetting
==
NULL
)
?
"NOK"
:
"OK"
);
}
prefix_elem1
=
strtok_r
(
NULL
,
"."
,
&
tokctx1
);
//skip the [x] elements we already took care of it
if
(
prefix_elem1
==
NULL
)
{
fprintf
(
stderr
,
"[LICONFIG] E
rror parsing %s__
\n
"
,
prefix
);
fprintf
(
stderr
,
"[LICONFIG] E
nd of parsing %s
\n
"
,
prefix
);
break
;
}
}
...
...
@@ -224,7 +266,7 @@ int config_libconfig_set(paramdef_t *cfgoptions, int numoptions, char *prefix )
}
free
(
prefixbck
);
if
(
asetting
!=
NULL
)
{
config_libconfig_setparams
(
cfgoptions
,
numoptions
,
asetting
);
config_libconfig_setparams
(
cfgoptions
,
numoptions
,
asetting
,
prefix
);
printf_params
(
"[LIBCONFIG] %i settings added in group %s
\n
"
,
numoptions
,(
prefix
==
NULL
)
?
""
:
prefix
);
return
0
;
}
else
{
...
...
@@ -534,10 +576,11 @@ void config_libconfig_end(void ) {
config_destroy
(
&
(
libconfig_privdata
.
cfg
));
if
(
cfgptr
->
rtflags
&
CONFIG_SAVERUNCFG
)
{
char
*
fname
=
strdup
(
libconfig_privdata
.
configfile
);
char
*
newcfgf
=
malloc
(
strlen
(
libconfig_privdata
.
configfile
+
20
));
int
newcfgflen
=
strlen
(
libconfig_privdata
.
configfile
)
+
strlen
(
cfgptr
->
tmpdir
)
+
20
;
char
*
newcfgf
=
malloc
(
newcfgflen
);
time_t
t
=
time
(
NULL
);
struct
tm
tm
=
*
localtime
(
&
t
);
s
printf
(
newcfgf
,
"%s/%s-run%d_%02d_%02d_%02d%02d"
,
cfgptr
->
tmpdir
,
basename
(
fname
),
s
nprintf
(
newcfgf
,
newcfgflen
,
"%s/%s-run%d_%02d_%02d_%02d%02d"
,
cfgptr
->
tmpdir
,
basename
(
fname
),
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
,
tm
.
tm_hour
,
tm
.
tm_min
);
if
(
config_write_file
(
&
(
libconfig_privdata
.
runtcfg
)
,
newcfgf
)
!=
CONFIG_TRUE
)
{
fprintf
(
stderr
,
"[LIBCONFIG] %s %d file %s - line %d: %s
\n
"
,
__FILE__
,
__LINE__
,
...
...
common/config/libconfig/config_libconfig.h
View file @
1fee616d
...
...
@@ -40,8 +40,6 @@ extern "C"
#include "common/config/config_paramdesc.h"
typedef
struct
libconfig_privatedata
{
char
*
configfile
;
...
...
executables/nr-ru.c
View file @
1fee616d
...
...
@@ -1494,7 +1494,8 @@ int start_rf(RU_t *ru) {
}
int
stop_rf
(
RU_t
*
ru
)
{
ru
->
rfdevice
.
trx_end_func
(
&
ru
->
rfdevice
);
if
(
ru
->
rfdevice
.
trx_end_func
)
ru
->
rfdevice
.
trx_end_func
(
&
ru
->
rfdevice
);
return
0
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment