2016-08-02 01:17:41 +00:00
|
|
|
//
|
|
|
|
|
// Copyright 2014 Ettus Research LLC
|
2018-02-19 23:30:32 +00:00
|
|
|
// Copyright 2018 Ettus Research, a National Instruments Company
|
2016-08-02 01:17:41 +00:00
|
|
|
//
|
2018-02-19 23:30:32 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
2016-08-02 01:17:41 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include <uhd/device3.hpp>
|
2017-02-08 00:37:25 +00:00
|
|
|
#include <uhd/utils/log.hpp>
|
2017-04-06 22:31:15 +00:00
|
|
|
#include <boost/format.hpp>
|
|
|
|
|
#include <boost/thread/lock_guard.hpp>
|
2016-08-02 01:17:41 +00:00
|
|
|
|
|
|
|
|
using namespace uhd;
|
|
|
|
|
using namespace uhd::rfnoc;
|
|
|
|
|
|
2020-03-03 20:52:17 +00:00
|
|
|
device3::sptr device3::make(const device_addr_t& hint, const size_t which)
|
2016-08-02 01:17:41 +00:00
|
|
|
{
|
|
|
|
|
device3::sptr device3_sptr =
|
2020-03-03 20:52:17 +00:00
|
|
|
boost::dynamic_pointer_cast<device3>(device::make(hint, device::USRP, which));
|
2016-08-02 01:17:41 +00:00
|
|
|
if (not device3_sptr) {
|
2020-03-03 20:52:17 +00:00
|
|
|
throw uhd::key_error(str(boost::format("No gen-3 devices found for ----->\n%s")
|
|
|
|
|
% hint.to_pp_string()));
|
2016-08-02 01:17:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return device3_sptr;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-03 20:52:17 +00:00
|
|
|
bool device3::has_block(const rfnoc::block_id_t& block_id) const
|
2016-08-02 01:17:41 +00:00
|
|
|
{
|
|
|
|
|
for (size_t i = 0; i < _rfnoc_block_ctrl.size(); i++) {
|
|
|
|
|
if (_rfnoc_block_ctrl[i]->get_block_id() == block_id) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-03 20:52:17 +00:00
|
|
|
block_ctrl_base::sptr device3::get_block_ctrl(const block_id_t& block_id) const
|
2016-08-02 01:17:41 +00:00
|
|
|
{
|
|
|
|
|
for (size_t i = 0; i < _rfnoc_block_ctrl.size(); i++) {
|
|
|
|
|
if (_rfnoc_block_ctrl[i]->get_block_id() == block_id) {
|
|
|
|
|
return _rfnoc_block_ctrl[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-03-03 20:52:17 +00:00
|
|
|
throw uhd::lookup_error(
|
|
|
|
|
str(boost::format("This device does not have a block with ID: %s")
|
|
|
|
|
% block_id.to_string()));
|
2016-08-02 01:17:41 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-03 20:52:17 +00:00
|
|
|
std::vector<rfnoc::block_id_t> device3::find_blocks(
|
|
|
|
|
const std::string& block_id_hint) const
|
2016-08-02 01:17:41 +00:00
|
|
|
{
|
|
|
|
|
std::vector<rfnoc::block_id_t> block_ids;
|
|
|
|
|
for (size_t i = 0; i < _rfnoc_block_ctrl.size(); i++) {
|
2019-11-27 04:59:28 +00:00
|
|
|
if (block_id_hint.empty()
|
|
|
|
|
|| _rfnoc_block_ctrl[i]->get_block_id().match(block_id_hint)) {
|
2016-08-02 01:17:41 +00:00
|
|
|
block_ids.push_back(_rfnoc_block_ctrl[i]->get_block_id());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return block_ids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void device3::clear()
|
|
|
|
|
{
|
2017-04-05 02:21:31 +00:00
|
|
|
boost::lock_guard<boost::mutex> lock(_block_ctrl_mutex);
|
2020-03-03 20:52:17 +00:00
|
|
|
for (const block_ctrl_base::sptr& block : _rfnoc_block_ctrl) {
|
2016-08-02 01:17:41 +00:00
|
|
|
block->clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// vim: sw=4 et:
|