[USRP-users] Possible fix for rfx dboards in db_rfx.cpp

Mike Weber miweber67 at gmail.com
Sun Mar 31 21:28:47 EDT 2019


It looks like when BOOST_FOREACH was replaced with c++ for( x: y ) style
iteration between release 3.10.3 and 3.11.0, a bug was introduced in
db_rfx.cpp that breaks these daughterboards. (Yes, I know it's EOL, but I
don't have funding for new ones, and they still do the job.) I don't have
the build environment set up so I can't test this diagnosis, but it looks
pretty clear.

The problem is that while the BOOST_FOREACH used macro replacement of an
existing variable P, which would be assigned the values from the dict and
retain them after the loop ended, the new for loop style uses the "auto"
keyword in front of the loop variable P, which effectively hides the P in
the outer scope which used to receive the selected value.

Old code:
int P=0;
BOOST_FOREACH(P, prescaler_to_enum.keys()){ ...

New code:
int P=0;
for(auto P:  prescaler_to_enum.keys()){ ...

Now, P stays zero, and we see errors like this:

------------------
C:\Program Files\UHD-3.11.0\bin>uhd_usrp_probe.exe --init-only
[INFO] [UHD] Win32; Microsoft Visual C++ version 14.0; Boost_105900;
UHD_3.11.0.0-release
[INFO] [USRP1] Opening a USRP1 device...
[INFO] [USRP1] Using FPGA clock rate of 64.000000MHz...
[ERROR] [DBMGR] The daughterboard manager encountered a recoverable error
in init.
Loading the "unknown" daughterboard implementations to continue.
The daughterboard cannot operate until this error is resolved.
LookupError: KeyError: key "0" not found in dict(int, enum
adf4360_regs_t::prescaler_value_t)
[ERROR] [DBMGR] The daughterboard manager encountered a recoverable error
in init.
Loading the "unknown" daughterboard implementations to continue.
The daughterboard cannot operate until this error is resolved.
LookupError: KeyError: key "0" not found in dict(int, enum
adf4360_regs_t::prescaler_value_t)
------------------

The fix may be as simple as removing the two auto keywords in that pair of
nested loops. Alternatively, the loop variables can be renamed and the
values of P and BS set explicitly when the loop finds the values it wants.

I would really like to use my existing fleet of USRP1s for some
demonstrations, so I'm hoping the above works. Let me know if there's
anything else I can do to help.

Best,
Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ettus.com/pipermail/usrp-users_lists.ettus.com/attachments/20190331/b2dec0e4/attachment.html>


More information about the USRP-users mailing list