aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-02-25 12:48:51 -0800
committerJosh Blum <josh@joshknows.com>2010-02-25 12:48:51 -0800
commit3571f65a1184dd65be39bc19708cc316fd017497 (patch)
treecc9c0f7600c6f72807ab12f0ed6307d079af29a6
parentc12d6d0f5f2bbfd749b5a18b167ed7a485cd03a1 (diff)
downloaduhd-3571f65a1184dd65be39bc19708cc316fd017497.tar.gz
uhd-3571f65a1184dd65be39bc19708cc316fd017497.tar.bz2
uhd-3571f65a1184dd65be39bc19708cc316fd017497.zip
use a single addr param for the usrp2
-rw-r--r--host/apps/discover_usrps.cpp14
-rw-r--r--host/lib/device.cpp7
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp4
3 files changed, 10 insertions, 15 deletions
diff --git a/host/apps/discover_usrps.cpp b/host/apps/discover_usrps.cpp
index 02c05b7cc..08135a27c 100644
--- a/host/apps/discover_usrps.cpp
+++ b/host/apps/discover_usrps.cpp
@@ -22,13 +22,12 @@
#include <iostream>
namespace po = boost::program_options;
-using namespace uhd;
int main(int argc, char *argv[]){
po::options_description desc("Allowed options");
desc.add_options()
("help", "help message")
- ("ip-addr", po::value<std::string>(), "usrp2 ip address")
+ ("addr", po::value<std::string>(), "resolvable network address")
;
po::variables_map vm;
@@ -41,13 +40,12 @@ int main(int argc, char *argv[]){
return ~0;
}
- //extract the ip address (not optional for now)
+ //extract the address (not optional for now)
uhd::device_addr_t device_addr;
- device_addr["type"] = "udp";
- if (vm.count("ip-addr")) {
- device_addr["addr"] = vm["ip-addr"].as<std::string>();
+ if (vm.count("addr")) {
+ device_addr["addr"] = vm["addr"].as<std::string>();
} else {
- std::cout << "IP Addess was not set" << std::endl;
+ std::cout << "The address was not set" << std::endl;
return ~0;
}
@@ -59,7 +57,7 @@ int main(int argc, char *argv[]){
std::cout << "--------------------------------------------------" << std::endl;
std::cout << device_addrs[i] << std::endl << std::endl;
//make each device just to test (TODO: remove this)
- uhd::device::sptr dev = device::make(device_addrs[i]);
+ uhd::device::sptr dev = uhd::device::make(device_addrs[i]);
std::cout << wax::cast<std::string>((*dev)[uhd::DEVICE_PROP_MBOARD][uhd::MBOARD_PROP_NAME]) << std::endl;
}
diff --git a/host/lib/device.cpp b/host/lib/device.cpp
index e376a5c50..f181d31e4 100644
--- a/host/lib/device.cpp
+++ b/host/lib/device.cpp
@@ -24,10 +24,7 @@ using namespace uhd;
device_addrs_t device::discover(const device_addr_t &hint){
device_addrs_t device_addrs;
- if (not hint.has_key("type")){
- //TODO call discover for others and append results
- }
- else if (hint["type"] == "udp"){
+ if (hint.has_key("addr")){
std::vector<device_addr_t> usrp2_addrs = usrp::usrp2::discover(hint);
device_addrs.insert(device_addrs.begin(), usrp2_addrs.begin(), usrp2_addrs.end());
}
@@ -53,7 +50,7 @@ device::sptr device::make(const device_addr_t &hint, size_t which){
//create the new device with the discovered address
//TODO only a usrp2 device will be made (until others are supported)
- if (hint.has_key("type") and hint["type"] == "udp"){
+ if (hint.has_key("addr")){
return usrp::usrp2::make(device_addrs.at(which));
}
throw std::runtime_error("cant make a device");
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index 11e2f480b..770fa3e53 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -60,8 +60,8 @@ uhd::device_addrs_t usrp2::discover(const device_addr_t &hint){
//make a boost asio ipv4 with the raw addr in host byte order
boost::asio::ip::address_v4 ip_addr(ntohl(ctrl_data_in.data.ip_addr));
device_addr_t new_addr;
- new_addr["name"] = "USRP2";
- new_addr["type"] = "udp";
+ new_addr["name"] = "usrp2";
+ new_addr["transport"] = "udp";
new_addr["addr"] = ip_addr.to_string();
usrp2_addrs.push_back(new_addr);
break;