multi_usrp: Add get_mb_controller() API call

This commit is contained in:
Cristina Fuentes 2020-09-21 15:17:39 -07:00 committed by Aaron Rossetto
parent bc20747808
commit 2e64cb1b28
5 changed files with 60 additions and 27 deletions

View file

@ -36,6 +36,7 @@
#include <uhd/usrp/dboard_iface.hpp>
#include <uhd/usrp/subdev_spec.hpp>
#include <uhd/utils/noncopyable.hpp>
#include <uhd/rfnoc/mb_controller.hpp>
#include <uhd/rfnoc/radio_control.hpp>
#include <complex>
#include <memory>
@ -1783,6 +1784,25 @@ public:
virtual void set_tx_filter(const std::string& name,
uhd::filter_info_base::sptr filter,
const size_t chan) = 0;
/*! Get direct access to the underlying mb_controller object.
*
* Note: This is an advanced API, created for corner cases where the
* application is using multi_usrp, but some special features from
* mb_controller need to be used that are not exposed by multi_usrp.
* Note that it is possible to put the mb_controller and multi_usrp into a
* broken state by directly accessing the mb_controller. For typical
* mb_controller operations it is therefore highly recommended
* to not use this API call, but use the native multi_usrp API calls.
*
* The lifetime of the mb_controller is linked to the lifetime of the
* device object, so storing a reference from this function is not allowed.
*
* \param mboard The motherboard index
* \returns A reference to the mb_controller for the corresponding mboard
* \throws uhd::not_implemented_error if not on an RFNoC device.
*/
virtual uhd::rfnoc::mb_controller& get_mb_controller(const size_t mboard = 0) = 0;
};
} // namespace usrp

View file

@ -2557,6 +2557,12 @@ public:
"set_gpio_src() not implemented for this motherboard!");
}
uhd::rfnoc::mb_controller& get_mb_controller(const size_t /*mboard*/)
{
throw uhd::not_implemented_error(
"get_mb_controller() not supported on this device!");
}
private:
device::sptr _dev;
property_tree::sptr _tree;

View file

@ -86,6 +86,7 @@ void export_multi_usrp(py::module& m)
.def("get_mboard_sensor_names" , &multi_usrp::get_mboard_sensor_names, py::arg("mboard") = 0)
.def("set_user_register" , &multi_usrp::set_user_register, py::arg("addr"), py::arg("data"), py::arg("mboard") = ALL_MBOARDS)
.def("get_radio_control" , &multi_usrp::get_radio_control, py::arg("chan") = 0)
.def("get_mb_controller" , &multi_usrp::get_mb_controller, py::arg("mboard") = 0)
// RX methods
.def("set_rx_subdev_spec" , &multi_usrp::set_rx_subdev_spec, py::arg("spec"), py::arg("mboard") = ALL_MBOARDS)

View file

@ -452,7 +452,7 @@ public:
{
auto& rx_chain = _get_rx_chan(chan);
const size_t mb_idx = rx_chain.radio->get_block_id().get_device_no();
auto mbc = get_mbc(mb_idx);
auto mbc = _get_mbc(mb_idx);
auto mb_eeprom = mbc->get_eeprom();
dict<std::string, std::string> usrp_info;
@ -486,7 +486,7 @@ public:
{
auto& tx_chain = _get_tx_chan(chan);
const size_t mb_idx = tx_chain.radio->get_block_id().get_device_no();
auto mbc = get_mbc(mb_idx);
auto mbc = _get_mbc(mb_idx);
auto mb_eeprom = mbc->get_eeprom();
dict<std::string, std::string> usrp_info;
@ -685,7 +685,7 @@ public:
% (_tree->access<std::string>("/name").get()));
for (size_t m = 0; m < get_num_mboards(); m++) {
buff += str(
boost::format(" Mboard %d: %s\n") % m % get_mbc(m)->get_mboard_name());
boost::format(" Mboard %d: %s\n") % m % _get_mbc(m)->get_mboard_name());
}
@ -718,29 +718,29 @@ public:
std::string get_mboard_name(size_t mboard = 0)
{
return get_mbc(mboard)->get_mboard_name();
return _get_mbc(mboard)->get_mboard_name();
}
time_spec_t get_time_now(size_t mboard = 0)
{
return get_mbc(mboard)->get_timekeeper(0)->get_time_now();
return _get_mbc(mboard)->get_timekeeper(0)->get_time_now();
}
time_spec_t get_time_last_pps(size_t mboard = 0)
{
return get_mbc(mboard)->get_timekeeper(0)->get_time_last_pps();
return _get_mbc(mboard)->get_timekeeper(0)->get_time_last_pps();
}
void set_time_now(const time_spec_t& time_spec, size_t mboard = ALL_MBOARDS)
{
MUX_MB_API_CALL(set_time_now, time_spec);
get_mbc(mboard)->get_timekeeper(0)->set_time_now(time_spec);
_get_mbc(mboard)->get_timekeeper(0)->set_time_now(time_spec);
}
void set_time_next_pps(const time_spec_t& time_spec, size_t mboard = ALL_MBOARDS)
{
MUX_MB_API_CALL(set_time_next_pps, time_spec);
get_mbc(mboard)->get_timekeeper(0)->set_time_next_pps(time_spec);
_get_mbc(mboard)->get_timekeeper(0)->set_time_next_pps(time_spec);
}
void set_time_unknown_pps(const time_spec_t& time_spec)
@ -858,33 +858,33 @@ public:
void set_time_source(const std::string& source, const size_t mboard = ALL_MBOARDS)
{
MUX_MB_API_CALL(set_time_source, source);
get_mbc(mboard)->set_time_source(source);
_get_mbc(mboard)->set_time_source(source);
}
std::string get_time_source(const size_t mboard)
{
return get_mbc(mboard)->get_time_source();
return _get_mbc(mboard)->get_time_source();
}
std::vector<std::string> get_time_sources(const size_t mboard)
{
return get_mbc(mboard)->get_time_sources();
return _get_mbc(mboard)->get_time_sources();
}
void set_clock_source(const std::string& source, const size_t mboard = ALL_MBOARDS)
{
MUX_MB_API_CALL(set_clock_source, source);
get_mbc(mboard)->set_clock_source(source);
_get_mbc(mboard)->set_clock_source(source);
}
std::string get_clock_source(const size_t mboard)
{
return get_mbc(mboard)->get_clock_source();
return _get_mbc(mboard)->get_clock_source();
}
std::vector<std::string> get_clock_sources(const size_t mboard)
{
return get_mbc(mboard)->get_clock_sources();
return _get_mbc(mboard)->get_clock_sources();
}
void set_sync_source(const std::string& clock_source,
@ -892,36 +892,36 @@ public:
const size_t mboard = ALL_MBOARDS)
{
MUX_MB_API_CALL(set_sync_source, clock_source, time_source);
get_mbc(mboard)->set_sync_source(clock_source, time_source);
_get_mbc(mboard)->set_sync_source(clock_source, time_source);
}
void set_sync_source(
const device_addr_t& sync_source, const size_t mboard = ALL_MBOARDS)
{
MUX_MB_API_CALL(set_sync_source, sync_source);
get_mbc(mboard)->set_sync_source(sync_source);
_get_mbc(mboard)->set_sync_source(sync_source);
}
device_addr_t get_sync_source(const size_t mboard)
{
return get_mbc(mboard)->get_sync_source();
return _get_mbc(mboard)->get_sync_source();
}
std::vector<device_addr_t> get_sync_sources(const size_t mboard)
{
return get_mbc(mboard)->get_sync_sources();
return _get_mbc(mboard)->get_sync_sources();
}
void set_clock_source_out(const bool enb, const size_t mboard = ALL_MBOARDS)
{
MUX_MB_API_CALL(set_clock_source_out, enb);
get_mbc(mboard)->set_clock_source_out(enb);
_get_mbc(mboard)->set_clock_source_out(enb);
}
void set_time_source_out(const bool enb, const size_t mboard = ALL_MBOARDS)
{
MUX_MB_API_CALL(set_time_source_out, enb);
get_mbc(mboard)->set_time_source_out(enb);
_get_mbc(mboard)->set_time_source_out(enb);
}
size_t get_num_mboards(void)
@ -931,12 +931,12 @@ public:
sensor_value_t get_mboard_sensor(const std::string& name, size_t mboard = 0)
{
return get_mbc(mboard)->get_sensor(name);
return _get_mbc(mboard)->get_sensor(name);
}
std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0)
{
return get_mbc(mboard)->get_sensor_names();
return _get_mbc(mboard)->get_sensor_names();
}
// This only works on the USRP2 and B100, both of which are not rfnoc_device
@ -2138,26 +2138,26 @@ public:
std::vector<std::string> get_gpio_src_banks(const size_t mboard = 0)
{
return get_mbc(mboard)->get_gpio_banks();
return _get_mbc(mboard)->get_gpio_banks();
}
std::vector<std::string> get_gpio_srcs(
const std::string& bank, const size_t mboard = 0)
{
return get_mbc(mboard)->get_gpio_srcs(bank);
return _get_mbc(mboard)->get_gpio_srcs(bank);
}
std::vector<std::string> get_gpio_src(
const std::string& bank, const size_t mboard = 0)
{
return get_mbc(mboard)->get_gpio_src(bank);
return _get_mbc(mboard)->get_gpio_src(bank);
}
void set_gpio_src(const std::string& bank,
const std::vector<std::string>& src,
const size_t mboard = 0)
{
get_mbc(mboard)->set_gpio_src(bank, src);
_get_mbc(mboard)->set_gpio_src(bank, src);
}
/*******************************************************************
@ -2405,11 +2405,16 @@ public:
}
}
mb_controller& get_mb_controller(const size_t mboard)
{
return *_get_mbc(mboard);
}
private:
/**************************************************************************
* Private Helpers
*************************************************************************/
mb_controller::sptr get_mbc(const size_t mb_idx)
mb_controller::sptr _get_mbc(const size_t mb_idx)
{
if (mb_idx >= get_num_mboards()) {
throw uhd::key_error(

View file

@ -589,6 +589,7 @@ def run_api_test(usrp):
'get_rx_dboard_iface',
'set_time_unknown_pps',
'get_radio_control',
'get_mb_controller',
]
success = True