diff options
-rw-r--r-- | host/include/uhd/utils/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/include/uhd/utils/images.hpp | 53 | ||||
-rw-r--r-- | host/include/uhd/utils/paths.hpp | 25 | ||||
-rw-r--r-- | host/lib/usrp/b100/b100_impl.cpp | 10 | ||||
-rw-r--r-- | host/lib/usrp/b100/b100_impl.hpp | 2 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_impl.cpp | 15 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_impl.hpp | 6 | ||||
-rw-r--r-- | host/lib/usrp/e100/e100_impl.cpp | 4 | ||||
-rw-r--r-- | host/lib/usrp/e300/e300_impl.cpp | 4 | ||||
-rw-r--r-- | host/lib/usrp/e300/e300_network.cpp | 2 | ||||
-rw-r--r-- | host/lib/usrp/usrp1/usrp1_impl.cpp | 4 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/usrp2_iface.cpp | 8 | ||||
-rw-r--r-- | host/lib/usrp/x300/x300_impl.cpp | 14 | ||||
-rw-r--r-- | host/lib/usrp_clock/octoclock/octoclock_impl.cpp | 6 | ||||
-rw-r--r-- | host/lib/utils/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/lib/utils/images.cpp | 54 | ||||
-rw-r--r-- | host/lib/utils/paths.cpp | 37 | ||||
-rw-r--r-- | host/utils/b2xx_fx3_utils.cpp | 2 | ||||
-rw-r--r-- | host/utils/octoclock_firmware_burner.cpp | 2 | ||||
-rw-r--r-- | host/utils/usrp_n2xx_simple_net_burner.cpp | 2 | ||||
-rw-r--r-- | host/utils/usrp_x3xx_fpga_burner.cpp | 2 |
21 files changed, 99 insertions, 155 deletions
diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt index c308c9cde..05f6892d2 100644 --- a/host/include/uhd/utils/CMakeLists.txt +++ b/host/include/uhd/utils/CMakeLists.txt @@ -25,7 +25,6 @@ UHD_INSTALL(FILES cast.hpp csv.hpp gain_group.hpp - images.hpp log.hpp math.hpp msg.hpp diff --git a/host/include/uhd/utils/images.hpp b/host/include/uhd/utils/images.hpp deleted file mode 100644 index a0934fb08..000000000 --- a/host/include/uhd/utils/images.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// -// Copyright 2010,2012 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); - - /*! - * Search for the location of the UHD Images Downloader script. - * \return the full system path to uhd_images_downloader.py - */ - - UHD_API std::string find_images_downloader(void); - - /*! - * Return the error string for recommending using the UHD Images Downloader. - * String depends on OS. - * \return the message suggesting the use of uhd_images_downloader.py - */ - - UHD_API std::string print_images_error(void); - -} //namespace uhd - -#endif /* INCLUDED_UHD_UTILS_IMAGES_HPP */ diff --git a/host/include/uhd/utils/paths.hpp b/host/include/uhd/utils/paths.hpp index e0f455e92..c1f32ba61 100644 --- a/host/include/uhd/utils/paths.hpp +++ b/host/include/uhd/utils/paths.hpp @@ -32,6 +32,31 @@ namespace uhd{ //! Get a string representing the system's pkg directory UHD_API std::string get_pkg_path(void); + /*! + * 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); + + /*! + * Search for the location of a particular UHD utility. + * The utility must be installed in the `uhd/utils` directory. + * \param the name of the utility to search for + * \return the full system path to @param + */ + UHD_API std::string find_utility(std::string name); + + /*! + * Return an error string recommending the user run the utility. + * The error string will include the full path to the utility to run. + * \return the message suggesting the use of the named utility. + */ + UHD_API std::string print_utility_error(std::string name); + } //namespace uhd #endif /* INCLUDED_UHD_UTILS_PATHS_HPP */ diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp index 24a87a3c8..c4279913c 100644 --- a/host/lib/usrp/b100/b100_impl.cpp +++ b/host/lib/usrp/b100/b100_impl.cpp @@ -23,7 +23,7 @@ #include <uhd/utils/cast.hpp> #include <uhd/exception.hpp> #include <uhd/utils/static.hpp> -#include <uhd/utils/images.hpp> +#include <uhd/utils/paths.hpp> #include <uhd/utils/safe_call.hpp> #include <boost/format.hpp> #include <boost/assign/list_of.hpp> @@ -82,7 +82,7 @@ static device_addrs_t b100_find(const device_addr_t &hint) b100_fw_image = find_image_path(hint.get("fw", B100_FW_FILE_NAME)); } catch(...){ - UHD_MSG(warning) << boost::format("Could not locate B100 firmware. %s\n") % print_images_error(); + UHD_MSG(warning) << boost::format("Could not locate B100 firmware. %s\n") % print_utility_error("uhd_images_downloader.py"); return b100_addrs; } UHD_LOG << "the firmware image: " << b100_fw_image << std::endl; @@ -532,10 +532,10 @@ void b100_impl::check_fw_compat(void){ ); if (fw_compat_num != B100_FW_COMPAT_NUM){ throw uhd::runtime_error(str(boost::format( - "Expected firmware compatibility number 0x%x, but got 0x%x:\n" + "Expected firmware compatibility number %d, but got %d:\n" "The firmware build is not compatible with the host code build.\n" "%s" - ) % B100_FW_COMPAT_NUM % fw_compat_num % print_images_error())); + ) % int(B100_FW_COMPAT_NUM) % fw_compat_num % print_utility_error("uhd_images_downloader.py"))); } _tree->create<std::string>("/mboards/0/fw_version").set(str(boost::format("%u.0") % fw_compat_num)); } @@ -552,7 +552,7 @@ void b100_impl::check_fpga_compat(void){ "Expected FPGA compatibility number %d, but got %d:\n" "The FPGA build is not compatible with the host code build." "%s" - ) % int(B100_FPGA_COMPAT_NUM) % fpga_major % print_images_error())); + ) % int(B100_FPGA_COMPAT_NUM) % fpga_major % print_utility_error("uhd_images_downloader.py"))); } _tree->create<std::string>("/mboards/0/fpga_version").set(str(boost::format("%u.%u") % fpga_major % fpga_minor)); } diff --git a/host/lib/usrp/b100/b100_impl.hpp b/host/lib/usrp/b100/b100_impl.hpp index 59ea2202e..dbca543be 100644 --- a/host/lib/usrp/b100/b100_impl.hpp +++ b/host/lib/usrp/b100/b100_impl.hpp @@ -46,7 +46,7 @@ static const double B100_LINK_RATE_BPS = 256e6/5; //pratical link rate (< 480 Mbps) static const std::string B100_FW_FILE_NAME = "usrp_b100_fw.ihx"; static const std::string B100_FPGA_FILE_NAME = "usrp_b100_fpga.bin"; -static const boost::uint16_t B100_FW_COMPAT_NUM = 0x04; +static const boost::uint16_t B100_FW_COMPAT_NUM = 4; static const boost::uint16_t B100_FPGA_COMPAT_NUM = 11; static const boost::uint32_t B100_RX_SID_BASE = 30; static const boost::uint32_t B100_TX_ASYNC_SID = 10; diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index 6d1172c98..b3c190c50 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -22,7 +22,7 @@ #include <uhd/utils/cast.hpp> #include <uhd/exception.hpp> #include <uhd/utils/static.hpp> -#include <uhd/utils/images.hpp> +#include <uhd/utils/paths.hpp> #include <uhd/utils/safe_call.hpp> #include <uhd/usrp/dboard_eeprom.hpp> #include <boost/format.hpp> @@ -115,7 +115,7 @@ static device_addrs_t b200_find(const device_addr_t &hint) UHD_MSG(warning) << boost::format( "Could not locate B200 firmware.\n" "Please install the images package. %s\n" - ) % print_images_error(); + ) % print_utility_error("uhd_images_downloader.py"); return b200_addrs; } UHD_LOG << "the firmware image: " << b200_fw_image << std::endl; @@ -791,11 +791,11 @@ void b200_impl::check_fw_compat(void) if (compat_major != B200_FW_COMPAT_NUM_MAJOR){ throw uhd::runtime_error(str(boost::format( - "Expected firmware compatibility number 0x%x, but got 0x%x.%x:\n" + "Expected firmware compatibility number %d.%d, but got %d.%d:\n" "The firmware build is not compatible with the host code build.\n" "%s" - ) % int(B200_FW_COMPAT_NUM_MAJOR) % compat_major % compat_minor - % print_images_error())); + ) % int(B200_FW_COMPAT_NUM_MAJOR) % int(B200_FW_COMPAT_NUM_MINOR) + % compat_major % compat_minor % print_utility_error("uhd_images_downloader.py"))); } _tree->create<std::string>("/mboards/0/fw_version").set(str(boost::format("%u.%u") % compat_major % compat_minor)); @@ -812,11 +812,10 @@ void b200_impl::check_fpga_compat(void) if (compat_major != B200_FPGA_COMPAT_NUM){ throw uhd::runtime_error(str(boost::format( - "Expected FPGA compatibility number 0x%x, but got 0x%x.%x:\n" + "Expected FPGA compatibility number %d, but got %d:\n" "The FPGA build is not compatible with the host code build.\n" "%s" - ) % int(B200_FPGA_COMPAT_NUM) % compat_major % compat_minor - % print_images_error())); + ) % int(B200_FPGA_COMPAT_NUM) % compat_major % print_utility_error("uhd_images_downloader.py"))); } _tree->create<std::string>("/mboards/0/fpga_version").set(str(boost::format("%u.%u") % compat_major % compat_minor)); diff --git a/host/lib/usrp/b200/b200_impl.hpp b/host/lib/usrp/b200/b200_impl.hpp index 22e962bd5..71592f60b 100644 --- a/host/lib/usrp/b200/b200_impl.hpp +++ b/host/lib/usrp/b200/b200_impl.hpp @@ -45,9 +45,9 @@ #include <uhd/transport/bounded_buffer.hpp> #include <boost/weak_ptr.hpp> #include "recv_packet_demuxer_3000.hpp" -static const boost::uint8_t B200_FW_COMPAT_NUM_MAJOR = 0x07; -static const boost::uint8_t B200_FW_COMPAT_NUM_MINOR = 0x00; -static const boost::uint16_t B200_FPGA_COMPAT_NUM = 0x04; +static const boost::uint8_t B200_FW_COMPAT_NUM_MAJOR = 7; +static const boost::uint8_t B200_FW_COMPAT_NUM_MINOR = 0; +static const boost::uint16_t B200_FPGA_COMPAT_NUM = 4; static const double B200_BUS_CLOCK_RATE = 100e6; static const double B200_DEFAULT_TICK_RATE = 32e6; static const double B200_DEFAULT_FREQ = 100e6; // Hz diff --git a/host/lib/usrp/e100/e100_impl.cpp b/host/lib/usrp/e100/e100_impl.cpp index 8b4f2316c..ac419e0e0 100644 --- a/host/lib/usrp/e100/e100_impl.cpp +++ b/host/lib/usrp/e100/e100_impl.cpp @@ -21,7 +21,7 @@ #include <uhd/utils/msg.hpp> #include <uhd/exception.hpp> #include <uhd/utils/static.hpp> -#include <uhd/utils/images.hpp> +#include <uhd/utils/paths.hpp> #include <boost/bind.hpp> #include <boost/format.hpp> #include <boost/filesystem.hpp> @@ -132,7 +132,7 @@ e100_impl::e100_impl(const uhd::device_addr_t &device_addr){ e100_fpga_image = find_image_path(device_addr.get("fpga", default_fpga_file_name)); } catch(...){ - UHD_MSG(error) << boost::format("Could not find FPGA image. %s\n") % print_images_error(); + UHD_MSG(error) << boost::format("Could not find FPGA image. %s\n") % print_utility_error("uhd_images_downloader.py"); throw; } e100_load_fpga(e100_fpga_image); diff --git a/host/lib/usrp/e300/e300_impl.cpp b/host/lib/usrp/e300/e300_impl.cpp index e42ac390e..8807a56e4 100644 --- a/host/lib/usrp/e300/e300_impl.cpp +++ b/host/lib/usrp/e300/e300_impl.cpp @@ -28,7 +28,7 @@ #include <uhd/utils/msg.hpp> #include <uhd/utils/log.hpp> #include <uhd/utils/static.hpp> -#include <uhd/utils/images.hpp> +#include <uhd/utils/paths.hpp> #include <uhd/usrp/dboard_eeprom.hpp> #include <uhd/transport/if_addrs.hpp> #include <uhd/transport/udp_zero_copy.hpp> @@ -397,7 +397,7 @@ e300_impl::e300_impl(const uhd::device_addr_t &device_addr) "%s" ) % fpga::COMPAT_MAJOR % _get_version(FPGA_MAJOR) % _get_version(FPGA_MINOR) - % print_images_error())); + % print_utility_error("uhd_images_downloader.py"))); } //////////////////////////////////////////////////////////////////// diff --git a/host/lib/usrp/e300/e300_network.cpp b/host/lib/usrp/e300/e300_network.cpp index 883ff0c4f..59e1eec86 100644 --- a/host/lib/usrp/e300/e300_network.cpp +++ b/host/lib/usrp/e300/e300_network.cpp @@ -33,7 +33,7 @@ #include <uhd/utils/msg.hpp> #include <uhd/utils/byteswap.hpp> -#include <uhd/utils/images.hpp> +#include <uhd/utils/paths.hpp> #include <boost/asio.hpp> #include <boost/thread.hpp> diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp index 709092e42..dbd5408e8 100644 --- a/host/lib/usrp/usrp1/usrp1_impl.cpp +++ b/host/lib/usrp/usrp1/usrp1_impl.cpp @@ -23,7 +23,7 @@ #include <uhd/utils/cast.hpp> #include <uhd/exception.hpp> #include <uhd/utils/static.hpp> -#include <uhd/utils/images.hpp> +#include <uhd/utils/paths.hpp> #include <boost/format.hpp> #include <boost/assign/list_of.hpp> #include <boost/filesystem.hpp> @@ -85,7 +85,7 @@ static device_addrs_t usrp1_find(const device_addr_t &hint) usrp1_fw_image = find_image_path(hint.get("fw", "usrp1_fw.ihx")); } catch(...){ - UHD_MSG(warning) << boost::format("Could not locate USRP1 firmware. %s") % print_images_error(); + UHD_MSG(warning) << boost::format("Could not locate USRP1 firmware. %s") % print_utility_error("uhd_images_downloader.py"); } UHD_LOG << "USRP1 firmware image: " << usrp1_fw_image << std::endl; diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index b2085807f..65cf90a17 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -23,7 +23,7 @@ #include <uhd/utils/msg.hpp> #include <uhd/utils/paths.hpp> #include <uhd/utils/tasks.hpp> -#include <uhd/utils/images.hpp> +#include <uhd/utils/paths.hpp> #include <uhd/utils/safe_call.hpp> #include <uhd/types/dict.hpp> #include <boost/thread.hpp> @@ -375,7 +375,7 @@ public: fpga_image_path = uhd::find_image_path(fpga_image); } catch(const std::exception &){ - return str(boost::format("Could not find %s and %s in your images path!\n%s") % fw_image % fpga_image % print_images_error()); + return str(boost::format("Could not find %s and %s in your images path!\n%s") % fw_image % fpga_image % print_utility_error("uhd_images_downloader.py")); } //escape char for multi-line cmd + newline + indent? @@ -389,13 +389,13 @@ public: if (this->get_rev() == USRP2_REV3 or this->get_rev() == USRP2_REV4){ const std::string card_burner = (fs::path(uhd::get_pkg_path()) / UHD_LIB_DIR / "uhd" / "utils" / "usrp2_card_burner.py").string(); const std::string card_burner_cmd = str(boost::format("\"%s%s\" %s--fpga=\"%s\" %s--fw=\"%s\"") % sudo % card_burner % ml % fpga_image_path % ml % fw_image_path); - return str(boost::format("%s\n%s") % print_images_error() % card_burner_cmd); + return str(boost::format("%s\n%s") % print_utility_error("uhd_images_downloader.py") % card_burner_cmd); } else{ const std::string addr = _ctrl_transport->get_recv_addr(); const std::string net_burner_path = (fs::path(uhd::get_pkg_path()) / UHD_LIB_DIR / "uhd" / "utils" / "usrp_n2xx_simple_net_burner").string(); const std::string net_burner_cmd = str(boost::format("\"%s\" %s--addr=\"%s\"") % net_burner_path % ml % addr); - return str(boost::format("%s\n%s") % print_images_error() % net_burner_cmd); + return str(boost::format("%s\n%s") % print_utility_error("uhd_images_downloader.py") % net_burner_cmd); } } diff --git a/host/lib/usrp/x300/x300_impl.cpp b/host/lib/usrp/x300/x300_impl.cpp index a879ae02d..8d255097d 100644 --- a/host/lib/usrp/x300/x300_impl.cpp +++ b/host/lib/usrp/x300/x300_impl.cpp @@ -24,7 +24,7 @@ #include "apply_corrections.hpp" #include <uhd/utils/static.hpp> #include <uhd/utils/msg.hpp> -#include <uhd/utils/images.hpp> +#include <uhd/utils/paths.hpp> #include <uhd/utils/safe_call.hpp> #include <uhd/usrp/subdev_spec.hpp> #include <uhd/transport/if_addrs.hpp> @@ -171,7 +171,7 @@ static device_addrs_t x300_find_pcie(const device_addr_t &hint, bool explicit_qu default: continue; } - + niriok_proxy::sptr kernel_proxy = niriok_proxy::make_and_open(dev_info.interface_path); //Attempt to read the name from the EEPROM and perform filtering. @@ -1670,11 +1670,11 @@ void x300_impl::check_fw_compat(const fs_path &mb_path, wb_iface::sptr iface) if (compat_major != X300_FW_COMPAT_MAJOR) { throw uhd::runtime_error(str(boost::format( - "Expected firmware compatibility number 0x%x, but got 0x%x.%x:\n" + "Expected firmware compatibility number %d.%d, but got %d.%d:\n" "The firmware build is not compatible with the host code build.\n" "%s" - ) % int(X300_FW_COMPAT_MAJOR) % compat_major % compat_minor - % print_images_error())); + ) % int(X300_FW_COMPAT_MAJOR) % int(X300_FW_COMPAT_MINOR) + % compat_major % compat_minor % print_utility_error("uhd_images_downloader.py"))); } _tree->create<std::string>(mb_path / "fw_version").set(str(boost::format("%u.%u") % compat_major % compat_minor)); @@ -1694,11 +1694,11 @@ void x300_impl::check_fpga_compat(const fs_path &mb_path, wb_iface::sptr iface) "Download the appropriate FPGA images for this version of UHD.\n" "%s\n\n" "Then burn a new image to the on-board flash storage of your\n" - "USRP X3xx device using the burner utility. \n\n" + "USRP X3xx device using the burner utility. %s\n\n" "For more information, refer to the UHD manual:\n\n" " http://files.ettus.com/manual/page_usrp_x3x0.html#x3x0_flash" ) % int(X300_FPGA_COMPAT_MAJOR) % compat_major - % print_images_error())); + % print_utility_error("uhd_images_downloader.py") % print_utility_error("usrp_x3xx_fpga_burner"))); } _tree->create<std::string>(mb_path / "fpga_version").set(str(boost::format("%u.%u") % compat_major % compat_minor)); diff --git a/host/lib/usrp_clock/octoclock/octoclock_impl.cpp b/host/lib/usrp_clock/octoclock/octoclock_impl.cpp index 8c207dd9f..d55fab10e 100644 --- a/host/lib/usrp_clock/octoclock/octoclock_impl.cpp +++ b/host/lib/usrp_clock/octoclock/octoclock_impl.cpp @@ -33,7 +33,7 @@ #include <uhd/usrp/gps_ctrl.hpp> #include <uhd/usrp_clock/octoclock_eeprom.hpp> #include <uhd/utils/byteswap.hpp> -#include <uhd/utils/images.hpp> +#include <uhd/utils/paths.hpp> #include <uhd/utils/msg.hpp> #include <uhd/utils/paths.hpp> #include <uhd/utils/static.hpp> @@ -420,7 +420,7 @@ std::string octoclock_impl::_get_images_help_message(const std::string &addr){ catch(const std::exception &e){ return str(boost::format("Could not find %s in your images path.\n%s") % image_name - % uhd::print_images_error()); + % uhd::print_utility_error("uhd_images_downloader.py")); } //Get escape character @@ -433,5 +433,5 @@ std::string octoclock_impl::_get_images_help_message(const std::string &addr){ //Get burner command const std::string burner_path = (fs::path(uhd::get_pkg_path()) / "bin" / "octoclock_firmware_burner").string(); const std::string burner_cmd = str(boost::format("%s %s--addr=\"%s\"") % burner_path % ml % addr); - return str(boost::format("%s\n%s") % uhd::print_images_error() % burner_cmd); + return str(boost::format("%s\n%s") % uhd::print_utility_error("uhd_images_downloader.py") % burner_cmd); } diff --git a/host/lib/utils/CMakeLists.txt b/host/lib/utils/CMakeLists.txt index 106e2b650..369920ac1 100644 --- a/host/lib/utils/CMakeLists.txt +++ b/host/lib/utils/CMakeLists.txt @@ -132,7 +132,6 @@ SET_SOURCE_FILES_PROPERTIES( LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/csv.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gain_group.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/images.cpp ${CMAKE_CURRENT_SOURCE_DIR}/load_modules.cpp ${CMAKE_CURRENT_SOURCE_DIR}/log.cpp ${CMAKE_CURRENT_SOURCE_DIR}/msg.cpp diff --git a/host/lib/utils/images.cpp b/host/lib/utils/images.cpp deleted file mode 100644 index 1ba2f81e6..000000000 --- a/host/lib/utils/images.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// -// Copyright 2010-2012 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 <uhd/exception.hpp> -#include <uhd/utils/paths.hpp> -#include <boost/foreach.hpp> -#include <boost/filesystem.hpp> -#include <vector> -#include <iostream> - -namespace fs = boost::filesystem; - -std::vector<fs::path> get_image_paths(void); //defined in paths.cpp - -/*********************************************************************** - * Find an 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).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.string(); - } - throw uhd::io_error("Could not find path for image: " + image_name + "\n\n" + uhd::print_images_error()); -} - -std::string uhd::find_images_downloader(void){ - return fs::path(fs::path(uhd::get_pkg_path()) / UHD_LIB_DIR / "uhd" / "utils" / "uhd_images_downloader.py").string(); -} - -std::string uhd::print_images_error(void){ - #ifdef UHD_PLATFORM_WIN32 - return "As an Administrator, please run:\n\n\"" + find_images_downloader() + "\""; - #else - return "Please run:\n\nsudo \"" + find_images_downloader() + "\""; - #endif -} diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp index 3e2bea1c6..282ebb566 100644 --- a/host/lib/utils/paths.cpp +++ b/host/lib/utils/paths.cpp @@ -17,15 +17,19 @@ #include <uhd/config.hpp> #include <uhd/utils/paths.hpp> -#include <boost/tokenizer.hpp> + +#include <boost/bind.hpp> +#include <uhd/exception.hpp> #include <boost/filesystem.hpp> #include <boost/foreach.hpp> -#include <boost/bind.hpp> +#include <boost/tokenizer.hpp> + +#include <cstdio> //P_tmpdir #include <cstdlib> +#include <iostream> #include <string> #include <vector> -#include <cstdlib> //getenv -#include <cstdio> //P_tmpdir + #ifdef BOOST_MSVC #define USE_GET_TEMP_PATH #include <windows.h> //GetTempPath @@ -136,3 +140,28 @@ std::string uhd::get_app_path(void){ return uhd::get_tmp_path(); } + +std::string uhd::find_image_path(const std::string &image_name){ + if (fs::exists(image_name)){ + return fs::system_complete(image_name).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.string(); + } + throw uhd::io_error("Could not find path for image: " + image_name + + "\n\n" + uhd::print_utility_error("uhd_images_downloader.py")); +} + +std::string uhd::find_utility(std::string name) { + return fs::path(fs::path(uhd::get_pkg_path()) / UHD_LIB_DIR / "uhd" / "utils" / name) + .string(); +} + +std::string uhd::print_utility_error(std::string name){ + #ifdef UHD_PLATFORM_WIN32 + return "As an Administrator, please run:\n\n\"" + find_utility(name) + "\""; + #else + return "Please run:\n\n \"" + find_utility(name) + "\""; + #endif +} diff --git a/host/utils/b2xx_fx3_utils.cpp b/host/utils/b2xx_fx3_utils.cpp index 0cab6618d..8b64be63e 100644 --- a/host/utils/b2xx_fx3_utils.cpp +++ b/host/utils/b2xx_fx3_utils.cpp @@ -39,7 +39,7 @@ #include <uhd/transport/usb_control.hpp> #include <uhd/transport/usb_device_handle.hpp> #include <uhd/exception.hpp> -#include <uhd/utils/images.hpp> +#include <uhd/utils/paths.hpp> namespace po = boost::program_options; namespace fs = boost::filesystem; diff --git a/host/utils/octoclock_firmware_burner.cpp b/host/utils/octoclock_firmware_burner.cpp index 9551ddd20..0a48caabd 100644 --- a/host/utils/octoclock_firmware_burner.cpp +++ b/host/utils/octoclock_firmware_burner.cpp @@ -37,7 +37,7 @@ #include <uhd/types/device_addr.hpp> #include <uhd/types/time_spec.hpp> #include <uhd/utils/byteswap.hpp> -#include <uhd/utils/images.hpp> +#include <uhd/utils/paths.hpp> #include <uhd/utils/paths.hpp> #include <uhd/utils/safe_main.hpp> diff --git a/host/utils/usrp_n2xx_simple_net_burner.cpp b/host/utils/usrp_n2xx_simple_net_burner.cpp index dc83b6fdf..b06e67bb2 100644 --- a/host/utils/usrp_n2xx_simple_net_burner.cpp +++ b/host/utils/usrp_n2xx_simple_net_burner.cpp @@ -38,7 +38,7 @@ #include <uhd/transport/udp_simple.hpp> #include <uhd/types/dict.hpp> #include <uhd/utils/byteswap.hpp> -#include <uhd/utils/images.hpp> +#include <uhd/utils/paths.hpp> #include <uhd/utils/safe_main.hpp> #include <uhd/utils/safe_call.hpp> diff --git a/host/utils/usrp_x3xx_fpga_burner.cpp b/host/utils/usrp_x3xx_fpga_burner.cpp index b849cfb92..abd5815e8 100644 --- a/host/utils/usrp_x3xx_fpga_burner.cpp +++ b/host/utils/usrp_x3xx_fpga_burner.cpp @@ -45,7 +45,7 @@ #include <uhd/device.hpp> #include <uhd/types/device_addr.hpp> #include <uhd/utils/byteswap.hpp> -#include <uhd/utils/images.hpp> +#include <uhd/utils/paths.hpp> #include <uhd/utils/safe_main.hpp> #include <uhd/utils/safe_call.hpp> |