Gr.prefs

Is there any kind of guide as to how gr.prefs is supposed to be used?
Is this functionality going
to be deprecated at any point, is there any kind of plan as to how it
will be used?


Principal Investigator
Shirleys Bay Radio Astronomy Consortium
http://www.sbrac.org

On Wed, 2010-04-28 at 15:28 -0400, Marcus D. Leech wrote:

Is there any kind of guide as to how gr.prefs is supposed to be used?
Is this functionality going
to be deprecated at any point, is there any kind of plan as to how it
will be used?

There is not much documentation but I found out the hard way a few
thinks you should know.

The format of the prefs configartion files:

-Never ever put a comment on the same line as a setting.

For example:
GOOD:

default fft_rate=15

fft_rate=8

BAD
fft_rate=8 # default fft_rate=15

This results in a parse error for the line, and consequently the default
being used (in this case 15) in stead of your value (in this case 8).

Comments should be on their own line, starting with a # with no
whitespace in front of the #.

-Don’t have backups of conf files (or other files) laying around in
(/usr/local)/etc/gnuradio/conf.d

All files in (/usr/local)/etc/gnuradio/conf.d will be parsed.

If you have gr-wxgui.conf and gr-wxgui.conf~ and gr-wxgui.conf.bak and
README.txt then all will be parsed in unknown order.
The last value parsed will be used.

The best way I found to find out which values are used from the prefs is
doing a grep on the whole gnuradio tree.
First find the files which use prefs

For C++ files:
grep -R “gr_prefs::singleton” *

For python files:
grep -R “gr.prefs” *

Then look in those files for get_string, get_long, get_…

Maybe it is also possible to tweak doxygen to show all uses of gr_prefs,
I haven’t tried.

To find out how to use it, just look at the current uses.
In short:
instantiate a gr_prefs singleton
in C++ gr_prefs::singleton()
in python gr.prefs()

And use one of the following methods to get your value:
get_xxxx(‘section_name’, ‘option_name’, default_value_if_not_found)

Where get_xxxx is get_bool, get_double, get_long,get_string or
get_long

Martin

Seems boost has something c++ based;
http://www.boost.org/doc/libs/1_42_0/doc/html/program_options/overview.html#id1419894

On Thu, Apr 29, 2010 at 09:12:33AM -0700, Josh B. wrote:

Seems boost has something c++ based; http://www.boost.org/doc/libs/1_42_0/doc/html/program_options/overview.html#id1419894

Thanks for the link!

Eric

On Thu, Apr 29, 2010 at 03:01:51PM +0200, Martin DvH wrote:

This results in a parse error for the line, and consequently the default
If you have gr-wxgui.conf and gr-wxgui.conf~ and gr-wxgui.conf.bak and
README.txt then all will be parsed in unknown order.
The last value parsed will be used.

Martin, We could probably change that to only loading *.conf without
breaking anything that matters. Feel free to fix it :slight_smile:

Marcus, there’s no plan to deprecate this. It’s used in quite a few
places such configuring the audio subsystem.

One thing to know about it, is that it’s currently dependent on python
to implement the real functionality. Thus it won’t work in C++ only
apps (unless somebody recodes the python to C++). There’s a pretty
much empty C++ class with virtual methods that’s overridden in python
using SWIG director magic.

Martin, the place to filter the list of files in
gnuradio-core/src/python/gnuradio/gr/prefs.py, line 72.

Eric

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs