summaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-04-20 12:05:33 -0700
committerJosh Blum <josh@joshknows.com>2010-04-20 12:05:33 -0700
commiteae0bec99bca5efa1e86faa03132ec5e8aca5fe5 (patch)
tree12a51e33d54293e2b7911f202fc5ae233fdae7ae /host/lib
parent6b015b1c517733e85cb0c08a379e8d20377bf2fa (diff)
downloaduhd-eae0bec99bca5efa1e86faa03132ec5e8aca5fe5.tar.gz
uhd-eae0bec99bca5efa1e86faa03132ec5e8aca5fe5.tar.bz2
uhd-eae0bec99bca5efa1e86faa03132ec5e8aca5fe5.zip
Created args string contructor for device address.
Using the args string for the find devices app. Added documentation to simple usrp.
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/types.cpp46
-rw-r--r--host/lib/usrp/simple_usrp.cpp39
2 files changed, 52 insertions, 33 deletions
diff --git a/host/lib/types.cpp b/host/lib/types.cpp
index 2a687f34f..91887840c 100644
--- a/host/lib/types.cpp
+++ b/host/lib/types.cpp
@@ -119,46 +119,44 @@ void time_spec_t::set_ticks(boost::uint32_t ticks, double tick_rate){
/***********************************************************************
* device addr
**********************************************************************/
-std::string device_addr_t::to_string(void) const{
- std::stringstream ss;
- BOOST_FOREACH(std::string key, this->keys()){
- ss << boost::format("%s: %s") % key % (*this)[key] << std::endl;
- }
- return ss.str();
-}
-
-static const std::string arg_delim = ";";
+static const std::string arg_delim = ",";
static const std::string pair_delim = "=";
static std::string trim(const std::string &in){
return boost::algorithm::trim_copy(in);
}
-std::string device_addr_t::to_args_str(void) const{
- std::string args_str;
- BOOST_FOREACH(const std::string &key, this->keys()){
- args_str += key + pair_delim + (*this)[key] + arg_delim;
- }
- return args_str;
-}
-
-device_addr_t device_addr_t::from_args_str(const std::string &args_str){
- device_addr_t addr;
-
+device_addr_t::device_addr_t(const std::string &args){
//split the args at the semi-colons
std::vector<std::string> pairs;
- boost::split(pairs, args_str, boost::is_any_of(arg_delim));
+ boost::split(pairs, args, boost::is_any_of(arg_delim));
BOOST_FOREACH(const std::string &pair, pairs){
if (trim(pair) == "") continue;
//split the key value pairs at the equals
std::vector<std::string> key_val;
boost::split(key_val, pair, boost::is_any_of(pair_delim));
- if (key_val.size() != 2) throw std::runtime_error("invalid args string: "+args_str);
- addr[trim(key_val[0])] = trim(key_val[1]);
+ if (key_val.size() != 2) throw std::runtime_error("invalid args string: "+args);
+ (*this)[trim(key_val[0])] = trim(key_val[1]);
}
+}
+
+std::string device_addr_t::to_string(void) const{
+ if (this->size() == 0) return "Empty Device Address";
+
+ std::stringstream ss;
+ BOOST_FOREACH(std::string key, this->keys()){
+ ss << boost::format("%s: %s") % key % (*this)[key] << std::endl;
+ }
+ return ss.str();
+}
- return addr;
+std::string device_addr_t::to_args_str(void) const{
+ std::string args_str;
+ BOOST_FOREACH(const std::string &key, this->keys()){
+ args_str += key + pair_delim + (*this)[key] + arg_delim;
+ }
+ return args_str;
}
/***********************************************************************
diff --git a/host/lib/usrp/simple_usrp.cpp b/host/lib/usrp/simple_usrp.cpp
index 11ee3a798..321d66a4a 100644
--- a/host/lib/usrp/simple_usrp.cpp
+++ b/host/lib/usrp/simple_usrp.cpp
@@ -42,14 +42,14 @@ public:
_tx_dsp = _mboard[MBOARD_PROP_TX_DSP];
//extract rx subdevice
- wax::obj rx_dboard = _mboard[MBOARD_PROP_RX_DBOARD];
- std::string rx_subdev_in_use = rx_dboard[DBOARD_PROP_USED_SUBDEVS].as<prop_names_t>().at(0);
- _rx_subdev = rx_dboard[named_prop_t(DBOARD_PROP_SUBDEV, rx_subdev_in_use)];
+ _rx_dboard = _mboard[MBOARD_PROP_RX_DBOARD];
+ std::string rx_subdev_in_use = _rx_dboard[DBOARD_PROP_USED_SUBDEVS].as<prop_names_t>().at(0);
+ _rx_subdev = _rx_dboard[named_prop_t(DBOARD_PROP_SUBDEV, rx_subdev_in_use)];
//extract tx subdevice
- wax::obj tx_dboard = _mboard[MBOARD_PROP_TX_DBOARD];
- std::string tx_subdev_in_use = tx_dboard[DBOARD_PROP_USED_SUBDEVS].as<prop_names_t>().at(0);
- _tx_subdev = tx_dboard[named_prop_t(DBOARD_PROP_SUBDEV, tx_subdev_in_use)];
+ _tx_dboard = _mboard[MBOARD_PROP_TX_DBOARD];
+ std::string tx_subdev_in_use = _tx_dboard[DBOARD_PROP_USED_SUBDEVS].as<prop_names_t>().at(0);
+ _tx_subdev = _tx_dboard[named_prop_t(DBOARD_PROP_SUBDEV, tx_subdev_in_use)];
}
~simple_usrp_impl(void){
@@ -61,7 +61,26 @@ public:
}
std::string get_name(void){
- return _mboard[MBOARD_PROP_NAME].as<std::string>();
+ return str(boost::format(
+ "Simple USRP:\n"
+ " Device: %s\n"
+ " Mboard: %s\n"
+ " RX DSP: %s\n"
+ " RX Dboard: %s\n"
+ " RX Subdev: %s\n"
+ " TX DSP: %s\n"
+ " TX Dboard: %s\n"
+ " TX Subdev: %s\n"
+ )
+ % (*_dev)[DEVICE_PROP_NAME].as<std::string>()
+ % _mboard[MBOARD_PROP_NAME].as<std::string>()
+ % _rx_dsp[DSP_PROP_NAME].as<std::string>()
+ % _rx_dboard[DBOARD_PROP_NAME].as<std::string>()
+ % _rx_subdev[SUBDEV_PROP_NAME].as<std::string>()
+ % _tx_dsp[DSP_PROP_NAME].as<std::string>()
+ % _tx_dboard[DBOARD_PROP_NAME].as<std::string>()
+ % _tx_subdev[SUBDEV_PROP_NAME].as<std::string>()
+ );
}
/*******************************************************************
@@ -174,6 +193,8 @@ private:
wax::obj _mboard;
wax::obj _rx_dsp;
wax::obj _tx_dsp;
+ wax::obj _rx_dboard;
+ wax::obj _tx_dboard;
wax::obj _rx_subdev;
wax::obj _tx_subdev;
};
@@ -181,6 +202,6 @@ private:
/***********************************************************************
* The Make Function
**********************************************************************/
-simple_usrp::sptr simple_usrp::make(const std::string &args){
- return sptr(new simple_usrp_impl(device_addr_t::from_args_str(args)));
+simple_usrp::sptr simple_usrp::make(const device_addr_t &dev_addr){
+ return sptr(new simple_usrp_impl(dev_addr));
}