summaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorNick Foster <nick@nerdnetworks.org>2010-08-19 18:02:35 -0700
committerNick Foster <nick@nerdnetworks.org>2010-08-19 18:02:35 -0700
commitc6ae773f4da476f2e314578b35d612b78893cf11 (patch)
tree6bfda0c898858ef4d19d057ff291eaaf0a8fa03a /host
parent769b565dbdc3fa1bb0891d4dcdbb74695f1dc875 (diff)
parentd99e22971975e9b5bfb966741684963be8f049f6 (diff)
downloaduhd-c6ae773f4da476f2e314578b35d612b78893cf11.tar.gz
uhd-c6ae773f4da476f2e314578b35d612b78893cf11.tar.bz2
uhd-c6ae773f4da476f2e314578b35d612b78893cf11.zip
Merge branch 'master' of ettus.sourcerepo.com:ettus/uhdpriv into usrp2p
Diffstat (limited to 'host')
-rw-r--r--host/docs/coding.rst7
-rw-r--r--host/docs/images.rst3
-rw-r--r--host/examples/CMakeLists.txt8
-rw-r--r--host/examples/tx_continuous_samples.cpp110
-rw-r--r--host/examples/tx_waveforms.cpp144
-rw-r--r--host/include/uhd/utils/CMakeLists.txt1
-rw-r--r--host/include/uhd/utils/images.hpp38
-rw-r--r--host/lib/usrp/misc_utils.cpp65
-rw-r--r--host/lib/utils/CMakeLists.txt1
-rw-r--r--host/lib/utils/images.cpp40
-rw-r--r--host/lib/utils/paths.cpp14
11 files changed, 271 insertions, 160 deletions
diff --git a/host/docs/coding.rst b/host/docs/coding.rst
index 84f9abf3e..23f350b0f 100644
--- a/host/docs/coding.rst
+++ b/host/docs/coding.rst
@@ -64,7 +64,12 @@ Integrating custom hardware
------------------------------------------------------------------------
Creators of custom hardware can create drivers that use the UHD API.
These drivers can be built as dynamically loadable modules that the UHD will load at runtime.
-For a module to be loaded at runtime, it must be found in the UHD_MODULE_PATH environment variable.
+
+For a module to be loaded at runtime, it must be:
+
+* found in the UHD_MODULE_PATH environment variable,
+* installed into the <prefix>/share/uhd/modules directory,
+* or installed into /usr/share/uhd/modules directory (unix only).
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Custom motherboard
diff --git a/host/docs/images.rst b/host/docs/images.rst
index ff5c5404e..612a00aa5 100644
--- a/host/docs/images.rst
+++ b/host/docs/images.rst
@@ -58,8 +58,7 @@ Where <prefix> was set by the CMAKE_INSTALL_PREFIX at configure-time.
**Option 2:**
Unpack the archive anywhere and set the UHD_IMAGE_PATH environment variable.
-The UHD_IMAGE_PATH may contain a list of directories to search for image files,
-or paths to specific image files.
+The UHD_IMAGE_PATH may contain a list of directories to search for image files.
------------------------------------------------------------------------
Building images
diff --git a/host/examples/CMakeLists.txt b/host/examples/CMakeLists.txt
index 10a9a833a..c3bbbcd04 100644
--- a/host/examples/CMakeLists.txt
+++ b/host/examples/CMakeLists.txt
@@ -16,9 +16,6 @@
#
-ADD_EXECUTABLE(tx_continuous_samples tx_continuous_samples.cpp)
-TARGET_LINK_LIBRARIES(tx_continuous_samples uhd)
-
ADD_EXECUTABLE(benchmark_rx_rate benchmark_rx_rate.cpp)
TARGET_LINK_LIBRARIES(benchmark_rx_rate uhd)
@@ -28,10 +25,13 @@ TARGET_LINK_LIBRARIES(rx_timed_samples uhd)
ADD_EXECUTABLE(tx_timed_samples tx_timed_samples.cpp)
TARGET_LINK_LIBRARIES(tx_timed_samples uhd)
+ADD_EXECUTABLE(tx_waveforms tx_waveforms.cpp)
+TARGET_LINK_LIBRARIES(tx_waveforms uhd)
+
INSTALL(TARGETS
- tx_continuous_samples
benchmark_rx_rate
rx_timed_samples
tx_timed_samples
+ tx_waveforms
RUNTIME DESTINATION ${PKG_DATA_DIR}/examples
)
diff --git a/host/examples/tx_continuous_samples.cpp b/host/examples/tx_continuous_samples.cpp
deleted file mode 100644
index cf70b07fb..000000000
--- a/host/examples/tx_continuous_samples.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-//
-// Copyright 2010 Ettus Research LLC
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-
-#include <uhd/utils/thread_priority.hpp>
-#include <uhd/utils/safe_main.hpp>
-#include <uhd/usrp/simple_usrp.hpp>
-#include <boost/program_options.hpp>
-#include <boost/thread/thread_time.hpp> //system time
-#include <boost/format.hpp>
-#include <iostream>
-#include <complex>
-
-namespace po = boost::program_options;
-
-int UHD_SAFE_MAIN(int argc, char *argv[]){
- uhd::set_thread_priority_safe();
-
- //variables to be set by po
- std::string args;
- size_t total_duration;
- size_t samps_per_packet;
- double tx_rate, freq;
- float ampl;
-
- //setup the program options
- po::options_description desc("Allowed options");
- desc.add_options()
- ("help", "help message")
- ("args", po::value<std::string>(&args)->default_value(""), "simple uhd device address args")
- ("duration", po::value<size_t>(&total_duration)->default_value(3), "number of seconds to transmit")
- ("spp", po::value<size_t>(&samps_per_packet)->default_value(1000), "number of samples per packet")
- ("txrate", po::value<double>(&tx_rate)->default_value(100e6/16), "rate of outgoing samples")
- ("freq", po::value<double>(&freq)->default_value(0), "rf center frequency in Hz")
- ("ampl", po::value<float>(&ampl)->default_value(float(0.3)), "amplitude of each sample")
- ("dilv", "specify to disable inner-loop verbose")
- ;
- po::variables_map vm;
- po::store(po::parse_command_line(argc, argv, desc), vm);
- po::notify(vm);
-
- //print the help message
- if (vm.count("help")){
- std::cout << boost::format("UHD TX Continuous Samples %s") % desc << std::endl;
- return ~0;
- }
-
- bool verbose = vm.count("dilv") == 0;
-
- //create a usrp device
- std::cout << std::endl;
- std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl;
- uhd::usrp::simple_usrp::sptr sdev = uhd::usrp::simple_usrp::make(args);
- uhd::device::sptr dev = sdev->get_device();
- std::cout << boost::format("Using Device: %s") % sdev->get_pp_string() << std::endl;
-
- //set properties on the device
- std::cout << boost::format("Setting TX Rate: %f Msps...") % (tx_rate/1e6) << std::endl;
- sdev->set_tx_rate(tx_rate);
- std::cout << boost::format("Actual TX Rate: %f Msps...") % (sdev->get_tx_rate()/1e6) << std::endl;
- sdev->set_tx_freq(freq);
-
- //allocate data to send
- std::vector<std::complex<float> > buff(samps_per_packet, std::complex<float>(ampl, ampl));
-
- //setup the metadata flags
- uhd::tx_metadata_t md;
- md.start_of_burst = true; //always SOB (good for continuous streaming)
- md.end_of_burst = false;
-
- //send the data in multiple packets
- boost::system_time end_time(boost::get_system_time() + boost::posix_time::seconds(total_duration));
- while(end_time > boost::get_system_time()){
- //send samples per packet (driver fragments internally)
- size_t num_tx_samps = dev->send(
- &buff.front(), samps_per_packet, md,
- uhd::io_type_t::COMPLEX_FLOAT32,
- uhd::device::SEND_MODE_FULL_BUFF
- );
- if(verbose) std::cout << std::endl << boost::format("Sent %d samples") % num_tx_samps << std::endl;
- }
-
- //send a mini EOB packet
- if(verbose) std::cout << std::endl << boost::format("Sending packet with end-of-burst") << std::endl;
- md.start_of_burst = false;
- md.end_of_burst = true;
- dev->send(
- NULL, 0, md,
- uhd::io_type_t::COMPLEX_FLOAT32,
- uhd::device::SEND_MODE_FULL_BUFF
- );
-
- //finished
- std::cout << std::endl << "Done!" << std::endl << std::endl;
-
- return 0;
-}
diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp
new file mode 100644
index 000000000..e9cf210bb
--- /dev/null
+++ b/host/examples/tx_waveforms.cpp
@@ -0,0 +1,144 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#include <uhd/utils/thread_priority.hpp>
+#include <uhd/utils/safe_main.hpp>
+#include <uhd/usrp/simple_usrp.hpp>
+#include <boost/program_options.hpp>
+#include <boost/thread/thread_time.hpp> //system time
+#include <boost/format.hpp>
+#include <iostream>
+#include <complex>
+#include <cmath>
+
+namespace po = boost::program_options;
+
+int UHD_SAFE_MAIN(int argc, char *argv[]){
+ uhd::set_thread_priority_safe();
+
+ //variables to be set by po
+ std::string args, wave_type;
+ size_t total_duration, amspb;
+ double rate, freq, wave_freq;
+ float ampl, gain;
+
+ //setup the program options
+ po::options_description desc("Allowed options");
+ desc.add_options()
+ ("help", "help message")
+ ("args", po::value<std::string>(&args)->default_value(""), "simple uhd device address args")
+ ("duration", po::value<size_t>(&total_duration)->default_value(3), "number of seconds to transmit")
+ ("amspb", po::value<size_t>(&amspb)->default_value(10000), "approximate mimimum samples per buffer")
+ ("rate", po::value<double>(&rate)->default_value(100e6/16), "rate of outgoing samples")
+ ("freq", po::value<double>(&freq)->default_value(0), "rf center frequency in Hz")
+ ("ampl", po::value<float>(&ampl)->default_value(float(0.3)), "amplitude of the waveform")
+ ("gain", po::value<float>(&gain)->default_value(float(0)), "gain for the RF chain")
+ ("wave-type", po::value<std::string>(&wave_type)->default_value("SINE"), "waveform type (CONST, SQUARE, RAMP, SINE)")
+ ("wave-freq", po::value<double>(&wave_freq)->default_value(0), "waveform frequency in Hz")
+ ;
+ po::variables_map vm;
+ po::store(po::parse_command_line(argc, argv, desc), vm);
+ po::notify(vm);
+
+ //print the help message
+ if (vm.count("help")){
+ std::cout << boost::format("UHD TX Waveforms %s") % desc << std::endl;
+ return ~0;
+ }
+
+ //create a usrp device
+ std::cout << std::endl;
+ std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl;
+ uhd::usrp::simple_usrp::sptr sdev = uhd::usrp::simple_usrp::make(args);
+ uhd::device::sptr dev = sdev->get_device();
+ std::cout << boost::format("Using Device: %s") % sdev->get_pp_string() << std::endl;
+
+ //set the tx sample rate
+ std::cout << boost::format("Setting TX Rate: %f Msps...") % (rate/1e6) << std::endl;
+ sdev->set_tx_rate(rate);
+ std::cout << boost::format("Actual TX Rate: %f Msps...") % (sdev->get_tx_rate()/1e6) << std::endl << std::endl;
+
+ //set the tx center frequency
+ std::cout << boost::format("Setting TX Freq: %f Mhz...") % (freq/1e6) << std::endl;
+ sdev->set_tx_freq(freq);
+ std::cout << boost::format("Actual TX Freq: %f Mhz...") % (sdev->get_tx_freq()/1e6) << std::endl << std::endl;
+
+ //set the tx rf gain
+ std::cout << boost::format("Setting TX Gain: %f dB...") % gain << std::endl;
+ sdev->set_tx_gain(gain);
+ std::cout << boost::format("Actual TX Gain: %f dB...") % sdev->get_tx_gain() << std::endl << std::endl;
+
+ //for the const wave, set the wave freq for small samples per period
+ if (wave_freq == 0 and wave_type == "CONST"){
+ wave_freq = sdev->get_tx_rate()/2;
+ }
+
+ //error when the waveform is not possible to generate
+ if (std::abs(wave_freq)/sdev->get_tx_rate() < 0.5/amspb){
+ throw std::runtime_error("wave freq/tx rate too small");
+ }
+ if (std::abs(wave_freq) > sdev->get_tx_rate()/2){
+ throw std::runtime_error("wave freq out of Nyquist zone");
+ }
+
+ //fill a buffer with one period worth of samples
+ std::vector<float> period(size_t(sdev->get_tx_rate()/std::abs(wave_freq)));
+ std::cout << boost::format("Samples per waveform period: %d") % period.size() << std::endl;
+ for (size_t n = 0; n < period.size(); n++){
+ if (wave_type == "CONST") period[n] = ampl;
+ else if (wave_type == "SQUARE") period[n] = (n > period.size()/2)? ampl : 0;
+ else if (wave_type == "RAMP") period[n] = float((n/double(period.size()-1)) * 2*ampl - ampl);
+ else if (wave_type == "SINE") period[n] = ampl*float(std::sin(2*M_PI*n/double(period.size())));
+ else throw std::runtime_error("unknown waveform type: " + wave_type);
+ }
+
+ //allocate data to send (fill with several periods worth of IQ samples)
+ const size_t periods_per_buff = std::max<size_t>(1, amspb/period.size());
+ std::vector<std::complex<float> > buff(period.size()*periods_per_buff);
+ std::cout << boost::format("Samples per send buffer: %d") % buff.size() << std::endl;
+ const size_t i_ahead = (wave_freq > 0)? period.size()/4 : 0;
+ const size_t q_ahead = (wave_freq < 0)? period.size()/4 : 0;
+ for (size_t n = 0; n < buff.size(); n++) buff[n] = std::complex<float>(
+ period[(n+i_ahead)%period.size()], period[(n+q_ahead)%period.size()] //I,Q
+ );
+
+ //setup the metadata flags
+ uhd::tx_metadata_t md;
+ md.start_of_burst = true; //always SOB (good for continuous streaming)
+ md.end_of_burst = false;
+
+ //send the data in multiple packets
+ boost::system_time end_time(boost::get_system_time() + boost::posix_time::seconds(total_duration));
+ while(end_time > boost::get_system_time()) dev->send(
+ &buff.front(), buff.size(), md,
+ uhd::io_type_t::COMPLEX_FLOAT32,
+ uhd::device::SEND_MODE_FULL_BUFF
+ );
+
+ //send a mini EOB packet
+ md.start_of_burst = false;
+ md.end_of_burst = true;
+ dev->send(NULL, 0, md,
+ uhd::io_type_t::COMPLEX_FLOAT32,
+ uhd::device::SEND_MODE_FULL_BUFF
+ );
+
+ //finished
+ std::cout << std::endl << "Done!" << std::endl << std::endl;
+
+ return 0;
+}
diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt
index ef8e64ce0..b39b6083c 100644
--- a/host/include/uhd/utils/CMakeLists.txt
+++ b/host/include/uhd/utils/CMakeLists.txt
@@ -23,6 +23,7 @@ INSTALL(FILES
byteswap.ipp
exception.hpp
gain_group.hpp
+ images.hpp
pimpl.hpp
props.hpp
safe_main.hpp
diff --git a/host/include/uhd/utils/images.hpp b/host/include/uhd/utils/images.hpp
new file mode 100644
index 000000000..8b5a1eedd
--- /dev/null
+++ b/host/include/uhd/utils/images.hpp
@@ -0,0 +1,38 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_UHD_UTILS_IMAGES_HPP
+#define INCLUDED_UHD_UTILS_IMAGES_HPP
+
+#include <uhd/config.hpp>
+#include <string>
+
+namespace uhd{
+
+ /*!
+ * Search for an image in the system image paths:
+ * Search compiled-in paths and environment variable paths
+ * for a specific image file with the provided file name.
+ * \param image_name the name of the file
+ * \return the full system path to the file
+ * \throw exception if the image was not found
+ */
+ UHD_API std::string find_image_path(const std::string &image_name);
+
+} //namespace uhd
+
+#endif /* INCLUDED_UHD_UTILS_IMAGES_HPP */
diff --git a/host/lib/usrp/misc_utils.cpp b/host/lib/usrp/misc_utils.cpp
index 46094ba32..a1664d810 100644
--- a/host/lib/usrp/misc_utils.cpp
+++ b/host/lib/usrp/misc_utils.cpp
@@ -25,6 +25,7 @@
#include <uhd/usrp/codec_props.hpp>
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
+#include <boost/format.hpp>
using namespace uhd;
using namespace uhd::usrp;
@@ -132,43 +133,49 @@ static void verify_xx_subdev_spec(
wax::obj mboard,
std::string xx_type
){
- prop_names_t dboard_names = mboard[dboard_names_prop].as<prop_names_t>();
- UHD_ASSERT_THROW(dboard_names.size() > 0); //well i hope there is a dboard
+ try{
+ prop_names_t dboard_names = mboard[dboard_names_prop].as<prop_names_t>();
+ UHD_ASSERT_THROW(dboard_names.size() > 0); //well i hope there is a dboard
- //the subdevice specification is empty: handle automatic
- if (subdev_spec.empty()){
- BOOST_FOREACH(const std::string &db_name, dboard_names){
- wax::obj dboard = mboard[named_prop_t(dboard_prop, db_name)];
+ //the subdevice specification is empty: handle automatic
+ if (subdev_spec.empty()){
+ BOOST_FOREACH(const std::string &db_name, dboard_names){
+ wax::obj dboard = mboard[named_prop_t(dboard_prop, db_name)];
+
+ //if the dboard slot is populated, take the first subdevice
+ if (dboard[DBOARD_PROP_DBOARD_ID].as<dboard_id_t>() != dboard_id_t::none()){
+ std::string sd_name = dboard[DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>().front();
+ subdev_spec.push_back(subdev_spec_pair_t(db_name, sd_name));
+ break;
+ }
+ }
- //if the dboard slot is populated, take the first subdevice
- if (dboard[DBOARD_PROP_DBOARD_ID].as<dboard_id_t>() != dboard_id_t::none()){
+ //didnt find any populated dboards: add the first subdevice
+ if (subdev_spec.empty()){
+ std::string db_name = dboard_names.front();
+ wax::obj dboard = mboard[named_prop_t(dboard_prop, db_name)];
std::string sd_name = dboard[DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>().front();
subdev_spec.push_back(subdev_spec_pair_t(db_name, sd_name));
- break;
}
}
- //didnt find any populated dboards: add the first subdevice
- if (subdev_spec.empty()){
- std::string db_name = dboard_names.front();
- wax::obj dboard = mboard[named_prop_t(dboard_prop, db_name)];
- std::string sd_name = dboard[DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>().front();
- subdev_spec.push_back(subdev_spec_pair_t(db_name, sd_name));
- }
- }
-
- //sanity check that the dboard/subdevice names exist for this mboard
- BOOST_FOREACH(const subdev_spec_pair_t &pair, subdev_spec){
- //empty db name means select dboard automatically
- if (pair.db_name.empty()){
- if (dboard_names.size() != 1) throw std::runtime_error(
- "A daughterboard name must be provided for multi-slot boards: " + subdev_spec.to_string()
- );
- pair.db_name == dboard_names.front();
+ //sanity check that the dboard/subdevice names exist for this mboard
+ BOOST_FOREACH(const subdev_spec_pair_t &pair, subdev_spec){
+ //empty db name means select dboard automatically
+ if (pair.db_name.empty()){
+ if (dboard_names.size() != 1) throw std::runtime_error(
+ "A daughterboard name must be provided for multi-slot boards: " + subdev_spec.to_string()
+ );
+ pair.db_name == dboard_names.front();
+ }
+ uhd::assert_has(dboard_names, pair.db_name, xx_type + " dboard name");
+ wax::obj dboard = mboard[named_prop_t(dboard_prop, pair.db_name)];
+ uhd::assert_has(dboard[DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>(), pair.sd_name, xx_type + " subdev name");
}
- uhd::assert_has(dboard_names, pair.db_name, xx_type + " dboard name");
- wax::obj dboard = mboard[named_prop_t(dboard_prop, pair.db_name)];
- uhd::assert_has(dboard[DBOARD_PROP_SUBDEV_NAMES].as<prop_names_t>(), pair.sd_name, xx_type + " subdev name");
+ }catch(const std::exception &e){
+ throw std::runtime_error(str(boost::format(
+ "Validate %s subdev spec failed: %s\n %s"
+ ) % xx_type % subdev_spec.to_string() % e.what()));
}
}
diff --git a/host/lib/utils/CMakeLists.txt b/host/lib/utils/CMakeLists.txt
index 68945545a..32b679d49 100644
--- a/host/lib/utils/CMakeLists.txt
+++ b/host/lib/utils/CMakeLists.txt
@@ -79,6 +79,7 @@ ENDIF(HAVE_DLFCN_H)
LIBUHD_APPEND_SOURCES(
${CMAKE_SOURCE_DIR}/lib/utils/assert.cpp
${CMAKE_SOURCE_DIR}/lib/utils/gain_group.cpp
+ ${CMAKE_SOURCE_DIR}/lib/utils/images.cpp
${CMAKE_SOURCE_DIR}/lib/utils/load_modules.cpp
${CMAKE_SOURCE_DIR}/lib/utils/paths.cpp
${CMAKE_SOURCE_DIR}/lib/utils/props.cpp
diff --git a/host/lib/utils/images.cpp b/host/lib/utils/images.cpp
new file mode 100644
index 000000000..395e542c1
--- /dev/null
+++ b/host/lib/utils/images.cpp
@@ -0,0 +1,40 @@
+//
+// Copyright 2010 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#include <uhd/utils/images.hpp>
+#include <boost/foreach.hpp>
+#include <boost/filesystem.hpp>
+#include <stdexcept>
+#include <vector>
+
+namespace fs = boost::filesystem;
+
+std::vector<fs::path> get_image_paths(void); //defined in paths.cpp
+
+/***********************************************************************
+ * Find a image in the image paths
+ **********************************************************************/
+std::string uhd::find_image_path(const std::string &image_name){
+ if (fs::exists(image_name)){
+ return fs::system_complete(image_name).file_string();
+ }
+ BOOST_FOREACH(const fs::path &path, get_image_paths()){
+ fs::path image_path = path / image_name;
+ if (fs::exists(image_path)) return image_path.file_string();
+ }
+ throw std::runtime_error("Could not find path for image: " + image_name);
+}
diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp
index 6ad12d3cc..9e9525caf 100644
--- a/host/lib/utils/paths.cpp
+++ b/host/lib/utils/paths.cpp
@@ -85,17 +85,3 @@ std::vector<fs::path> get_module_paths(void){
paths.push_back(fs::path(INSTALLER_PKG_DATA_DIR) / "modules");
return paths;
}
-
-/***********************************************************************
- * Find a image in the image paths
- **********************************************************************/
-std::string find_image_path(const std::string &image_name){
- if (fs::exists(image_name)){
- return fs::system_complete(image_name).file_string();
- }
- BOOST_FOREACH(const fs::path &path, get_image_paths()){
- fs::path image_path = path / image_name;
- if (fs::exists(image_path)) return image_path.file_string();
- }
- throw std::runtime_error("Could not find path for image: " + image_name);
-}