From be0df323ca8eccee6abb19d54ebdd0cbbe12d9a4 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 23 Jan 2018 18:12:55 -0800 Subject: utils: Use find_all in uhd_find_devices This enables finding all N310 devices, even if they're not available Reviewed-by: Brent Stapleton --- host/utils/uhd_find_devices.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'host') diff --git a/host/utils/uhd_find_devices.cpp b/host/utils/uhd_find_devices.cpp index 697a482fb..8454afb4d 100644 --- a/host/utils/uhd_find_devices.cpp +++ b/host/utils/uhd_find_devices.cpp @@ -10,6 +10,20 @@ #include #include #include + +namespace { + //! Conditionally append find_all=1 if the key isn't there yet + uhd::device_addr_t append_findall(const uhd::device_addr_t& device_args) + { + uhd::device_addr_t new_device_args(device_args); + if (!new_device_args.has_key("find_all")) { + new_device_args["find_all"] = "1"; + } + + return new_device_args; + } +} + namespace po = boost::program_options; int UHD_SAFE_MAIN(int argc, char *argv[]){ @@ -26,13 +40,14 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //print the help message if (vm.count("help")){ std::cout << boost::format("UHD Find Devices %s") % desc << std::endl; - return EXIT_FAILURE; + return EXIT_SUCCESS; } //discover the usrps and print the results - uhd::device_addrs_t device_addrs = uhd::device::find(vm["args"].as()); - - if (device_addrs.size() == 0){ + const uhd::device_addr_t args(vm["args"].as()); + uhd::device_addrs_t device_addrs = + uhd::device::find(append_findall(args)); + if (device_addrs.empty()) { std::cerr << "No UHD Devices Found" << std::endl; return EXIT_FAILURE; } -- cgit v1.2.3