diff options
author | Nicholas Corgan <nick.corgan@ettus.com> | 2015-08-05 08:46:28 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2015-08-05 13:04:04 -0700 |
commit | bb62ab84fdad6f7cf18ea55d395dfbd7f11ed79d (patch) | |
tree | ab9bb3a78f10661e12b832c9c341d027463739ba /host/lib/usrp/x300 | |
parent | c3c9513b9b5f67afe4233659222fdfc5bbb2511c (diff) | |
download | uhd-bb62ab84fdad6f7cf18ea55d395dfbd7f11ed79d.tar.gz uhd-bb62ab84fdad6f7cf18ea55d395dfbd7f11ed79d.tar.bz2 uhd-bb62ab84fdad6f7cf18ea55d395dfbd7f11ed79d.zip |
image_loader: force user to specify device
* On utility level, force user to use --args=type=foo
* In each loader, throw an error if args are ambiguous
Diffstat (limited to 'host/lib/usrp/x300')
-rw-r--r-- | host/lib/usrp/x300/x300_image_loader.cpp | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/host/lib/usrp/x300/x300_image_loader.cpp b/host/lib/usrp/x300/x300_image_loader.cpp index 321309868..9ec8a2e13 100644 --- a/host/lib/usrp/x300/x300_image_loader.cpp +++ b/host/lib/usrp/x300/x300_image_loader.cpp @@ -158,17 +158,31 @@ static void x300_validate_image(x300_session_t &session){ static void x300_setup_session(x300_session_t &session, const device_addr_t &args, const std::string &filepath){ - device_addr_t find_args; - find_args["type"] = "x300"; - if(args.has_key("name")) find_args["name"] = args["name"]; - if(args.has_key("serial")) find_args["serial"] = args["serial"]; - if(args.has_key("ip-addr")) find_args["addr"] = args["ip-addr"]; - else if(args.has_key("resource")) find_args["resource"] = args["resource"]; - device_addrs_t devs = x300_find(args); - session.found = (devs.size() > 0); - if(!session.found) return; + if(devs.size() == 0){ + session.found = false; + return; + } + else if(devs.size() > 1){ + std::string err_msg = "Could not resolve given args to a single X-Series device.\n" + "Applicable devices:\n"; + + BOOST_FOREACH(const uhd::device_addr_t &dev, devs){ + std::string identifier = dev.has_key("addr") ? "addr" + : "resource"; + + err_msg += str(boost::format(" * %s (%s=%s)\n") + % dev.get("product", "X3XX") + % identifier + % dev.get(identifier)); + } + + err_msg += "\nSpecify one of these devices with the given args to load an image onto it."; + + throw uhd::runtime_error(err_msg); + } + session.found = true; session.dev_addr = devs[0]; session.ethernet = session.dev_addr.has_key("addr"); if(session.ethernet){ |